Supposing we have the following element <p id="abc">Hello World</p>
. If I want to modify the content in the <p>
tag I have two ways in the javascript code:
document.getElementById("abc").innerHTML="good morning";
document.getElementById("abc").firstChild.nodeValue="good morning";
The questions are:
- Which are the difference between the 2 solutions?
- Which one should I use? Is there one better than the other?