Dynamically add html elements and simple examples of attributes with js
function test(){//create node var lswt_2=document.createElement("div");//Set node idlswt_2.id='lswtColse';//Set node attribute lswt_2.style.width='11px';lswt_2.style.height='10px';lswt_2.style.top='0px';lswt_2.style.right='0px';lswt_2.style.right='0px';lswt_2.style.right='0px';ls wt_2.style.position='absolute';lswt_2.style.background='url(7.gif)';lswt_2.style.backgroundRepeat='no-repeat';//Add click time for this node lswt_4.addEventListener("click",loc,false);//Where to put this node? Put the element with id lswt var element_2=document.getElementById("lswt");//Insert this node element_2.appendChild(lswt_2);}The above article dynamically adding html elements and attributes using js is all the content I share with you. I hope you can give you a reference and I hope you can support Wulin.com more.