Home >Web Front-end >JS Tutorial >Summary of js copying or inserting Html implementation methods_javascript skills
var bq=document.getElementsByTagName("Tag or ID name")//ID is a unique grouping, the tag is not unique, and an array may be returned.
div=document.createElement("div");
...Set CSS style
bq.appendChild(div); //This is all you need for ID uniqueness! Insert the div layer after bq
bq[0].appendChild(div);//If the tag is used before! Arrays and subscripts! Insert the div layer after bq
bq.insertBefore(div);//This is all you need for ID uniqueness! Insert the div layer before bq
bq[0].insertBefore(div);//If the tag is used before! Arrays and subscripts! Insert a div layer before bq
document.getElementById('navition').style.cssText = 'Your CSS code';
//Copy a div
var bq=document.getElementById( "Copy")//ID is the only allowed grouping, the label is not unique, and may return an array.
objDiv=document.createElement("div");
objDiv.id=bq.id Copy;
objDiv.style.position="absolute"
objDiv.style.left="200px"
objDiv.style.top="200px"
objDiv.innerHTML=bq.innerHTML;
bq .appendChild(objDiv);