why the event does not leave changes, but applies only for a moment (when a button is pressed)

(function(){ var addWant = document.getElementById("add"), newDiv = document.createElement("div"), content = document.createTextNode("will here want."), includeDivHere = document.getElementById("createWant"); addWant.onclick = function(){ newDiv.className = "wantClass"; newDiv.appendChild(content); includeDivHere.parentNode.appendChild(newDiv); console.log(newDiv); }; })(); 
  • In general, what is the value in this context, in your opinion? And what is the "effect"? Text that is inserted into the element with id = "n"? Or creating a new div? More specifically. - Mikhail Naletov September
  • 'wantClass' is applied and disappears immediately the same with document.getElementById ('n'). value = 'is work it'; - Zein
  • Maybe you still have a click listener besides that? - zb '

1 answer 1

 document.getElementById('n').innerText = 'is work it'; 

So the text in the element with id = "n" is inserted.

  • With this option, the text is not drawn for half a second. - Zein
  • I do not think so jsfiddle.net/bmsdfxwp - Mikhail Naletov
  • strange, but all my browsers refuse to behave normally with this code ... - Zein
  • For me, only Ognelis did not want to add text to the div, the others were ok (even a donkey). - Mikhail Naletov
  • innerText not supported everywhere, use innerHTML - Deonis