Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.2 kB
1
Indexable
Never
var htmls = items.map(function (item) {
        var btn = acc == ''
            ? `` : ` 
        <button class="btnEdit" onclick="handleEditItem(${item.id})">
            Xem
        </button>
        <button class="btnDelete" onclick="handleDeleteItem(${item.id})">
            Xóa
        </button>`
        id++
        color = id % 2 == 0 ? 'gray' : 'white'
        return `
            <div class="itemList2 ${color}">
                <div class="itemListElement renderId"><h4 class="text-align">${id}</h4></div>
                <div class="itemListElement titleBook"><h4 class="text-align">${item.title}</h4></div>
                <div class="itemListElement"><h4 class="text-align">${item.auth}</h4></div>
                <div class="itemListElement"><h4 class="text-align">${item.category}</h4></div>
                <div class="itemListElement"><h4 class="text-align">${item.update_day}</h4></div>
                <div class="itemListElement renderId"><h4 class="text-align">${item.num_of_pages}</h4></div>
                <div class="itemListElement">
                   ${btn}
                </div>
            </div>
        `
    })
    document.querySelector('#list').innerHTML = htmls.join('')