+ 2

How can we change the text value of an HTML elemen in js

24th Dec 2017, 6:36 PM
Muhmd Ezz
Muhmd Ezz - avatar
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
24th Dec 2017, 7:11 PM
Morpheus
Morpheus - avatar
+ 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
24th Dec 2017, 7:15 PM
Morpheus
Morpheus - avatar
+ 2
use element.textContent= "your text", and try to avoid innerText and innerHTML , If it's only text
24th Dec 2017, 6:46 PM
Morpheus
Morpheus - avatar
+ 1
can we use innerhtml or title or nodevalue?
24th Dec 2017, 6:58 PM
Muhmd Ezz
Muhmd Ezz - avatar
+ 1
lol...use document.getElementById("demo").innerHTML="hello this is my test out j.s code";
24th Dec 2017, 7:34 PM
Android Boi
Android Boi - avatar