JS node, are aware of 3 major categories:
ELEMENT node
Attribute node
Text node
The common element node, the attribute node. There are two ways, SetAttribute () getattribute (), setting and getting property values
In the actual work, long we get a bunch of data from backstage, to show on the front page.
After we have written an HTML master, we use the For loop to add data to the master and finally insert the page. This is the idea!
In order to be quick and convenient, often doing so,
var str= "";
for (Var i=0;i<data.length;i++) {
str+= "<div>" +data[i].detail+ "</div>";
}
$ (' div '). Innerhtml=str;
But this, the impact of page performance, in setting some properties of what is inconvenient, too many strings splicing error, it is important to appear very unprofessional!!
Under the great God's point, start with this ghost!
var fragment=document.createdocumentfragment ();
Fragment is a node fragment.
Now we can do this.
for (Var i=0;i<data.length;i++) {
var div=document.createelement (' div ');
Div.classname= "ML";
Div.innerhtml=data[i].detail;
Fragment.appendchild (DIV);
}
$ (' div '). appendchild (fragment);
So look at the big on it!!!
JS node using fragment node