javascript - HTML DOM innerHTML Property -
change html content of <p>
element id="demo"
:
document.getelementbyid("demo").innerhtml = "paragraph changed!";
is right way change html content?
if want change contents use
document.getelementbyid("demo").innertext = "paragraph changed!";
or want change html tags use,
document.getelementbyid("demo").innerhtml = "<h2>heading changed!</h2>";
another method
document.getelementbyid("demo").firstchild.nodevalue = "paragraph changed!";
Comments
Post a Comment