The use of innerHTML
Tablerowobject.innerhtml
The use of createTextNode
createTextNode (data)
Returns the newly created Text node that represents the specified data string.
Difference: 1) innerHTML belongs to the HTML Dom
createTextNode belongs to the XML Dom
2) Although the effect is similar but in some cases there is a difference
1 var p=document.createelement ("P"); 2 p.classname= "message"; 3 p.innerhtml= "<b>i love js</b>"; 4 Document.body.appendChild (p);
1 var p=document.createelement ("P"); 2 p.classname= "message"; 3 var textnode=document.createtextnode ("<b>i love Js</b>"); 4 P.appendchild (textnode); 5 Document.body.appendChild (p);
In the first case the rendered effect is bold text content
In the second case, the effect is <b>i love js</b> the original text.
So the difference between the two is that innerHTML will implement the HTML code contained in the text, while createTextNode simply creates the text node, so the effect returned is the plain text content.
The difference between Innerhtl and createTextNode