I have this JavaScript function and I want to have the same but in jQuery but it's not working correctly, the list items are not appearing:
function showList(section, books) {
let olBooks = document.createElement("ol");
let liBook = null;
for (let book of books) {
liBook = document.createElement("li");
liBook.id = value.id;
liBook.classList.add(CLASS_BOOK);
liBook.innerHTML = "<p>" + booksInHTML(book) + "</p>";
olBooks.appendChild(liBook);
}
section.append(olBooks);
}
With jQuery is not working:
function showList(section, books) {
var olBooks = $("<ol/>");
$.each( books, function( index, value ) {
var liBook = $("<li/>");
liBook.id = value.id;
liBook.classList.add(CLASS_BOOK);
liBook.text("<p>" + bookInHTML(value) + "</p>");
olBooks.append(liBook);
});
section.append(olBooks);
}