+ 2
How can we change the text value of an HTML elemen in js
7 Answers
+ 3
@martin Taylor, I said to avoid inneraHTML for main reason to avoid any possible cross scripting attacks , https://stackoverflow.com/questions/30661497/xss-prevention-and-innerhtml
+ 3
in short, when u use , innerHTML , then chances increases for attackers to run their scripts on your page, few famous recent examples was of infinite alert boxes opening on many websites just after loading , eventually leading to client side crash
+ 2
use
element.textContent= "your text",
and try to avoid
innerText and innerHTML , If it's only text
+ 1
can we use innerhtml or title or nodevalue?
+ 1
lol...use document.getElementById("demo").innerHTML="hello this is my test out j.s code";