html - How to set Id to button created using Javascript? -
// how set id created buttons?
for(i=1;i<=3;i++) { var btn = document.createelement("button");// create button using java script btn.classname = "btnsize"; var txt = document.createtextnode(num++);//creat text on button btn.appendchild(txt);//attached text on button document.getelementbyid("xyz").appendchild(btn);//atache button text in div }
for (i = 1; <= 3; i++) { var btn = document.createelement("button"); btn.setattribute("class","btnsize"); btn.setattribute("id","btnid"+i); var txt = document.createtextnode("button"); btn.appendchild(txt); document.getelementbyid("xyz").appendchild(btn); }
Comments
Post a Comment