I am writing a script that takes a book as some array of sentences. I want to print each sentence out, then make each sentence clickable. Right now, I have it printing each sentence, but when I attempt to append a
element with it's own unique id for each sentence, it does not work. here is my jsfidde: http://jsfiddle.net/mvvq8L7p/
Relevant code snippet.
var IdCounter = 0;
for (var i = 0, len = book_sentences.length; i < len; i++) {
IdCounter++;
document.getElementById("pageOfBook").innerHTML = "<p class='sentence' id='sentence#" + IdCounter + "'>" + book_sentences[i] + "</p>";
}
Can anyone explain why this occurs and how to make it work? Thanks in advance, I really appreciate the help!
'.'?