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

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -