Reputation: 17
Hey I have a problem with one loop: I need to put html into JavaScript because it is a meme. Here is the code which is working fine but using document.write. I don't want use document.write as it is not working on Firefox:
for (var m = 1; m < 5; m++) {
document.write("<li onClick=\"hello2()\"><a href=\"#\"><script>document.write(wynik)<\/script><\/a><\/li>");
}
I tried to use:
document.getElementById('menu').innerHTML = "<li onClick=\"hello2()\"><a href=\"#\"><Script>document.write(wynik)<\/script><\/a><\/li>");
But it is not working porperly. Wrong format and showing only once in the loop.
Any suggestions ?
Upvotes: 0
Views: 66
Reputation: 1422
document.getElementById('menu').innerHTML += "<li onClick=\"hello2()\"><a href=\"#\">" + wynik + "<\/a><\/li>";
Use +=
and remove )
then it will get work..
Upvotes: 2