Dynamic addition of html elements with js as well as simple instances of attributes
- 2021-07-04 17:55:10
- OfStack
Dynamic addition of html elements with js, as well as simple instances of attributes
function test(){
// Create Node
var lswt_2=document.createElement("div");
// Setting Node id
lswt_2.id='lswtColse';
// Setting node properties
lswt_2.style.width='11px';
lswt_2.style.height='10px';
lswt_2.style.top='0px';
lswt_2.style.right='0px';
lswt_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 do you put this node? Put id For lswt Under the element of
var element_2=document.getElementById("lswt");
// Insert this node
element_2.appendChild(lswt_2);
}