Hi
I’ve been struggling to adapt this code which pulls in books currently reading from Readernaut. At the moment this will pull in the book cover, but I want to add the title in text next to the cover with a permalink.
I can get the text by using document.write but I can’t work out how to add the element so it’s a link or can be styled with CSS.
Any help much appreciated.
Thanks
function parseResponse(data) {
var bookshelf = document.getElementById("bookshelf");
for (var i=0; i<1; i++) {
var cover = data.reader_books[i].book_edition.covers.cover_medium;
var title = data.reader_books[i].book_edition.title;
var permalink = data.reader_books[i].permalink;
var link = document.createElement("a");
link.setAttribute("href",permalink);
var img = document.createElement("img");
img.setAttribute("src",cover);
img.setAttribute("alt",title);
link.appendChild(img);
bookshelf.appendChild(link);
}
}