使用Javascript在html上创建复选框 [英] create checkbox on html using Javascript
问题描述
大家好,
你能否帮我看看如何使用Javascript在html上创建复选框。
我有数组表 作为ElmArray =H2O,SIO2,Ni,Fe,MGO,Al,CaO
谢谢
Yusran
var myDiv = document.getElementById(myDiv);
var checkbox = document.createElement(input);
checkbox.setAttribute(type,checkbox);
checkbox.setAttribute(name,dd);
checkbox.setAttribute (价值,ff);
checkbox.checked = true;
myDiv.appendChild(复选框);
//追加后执行此操作
checkbox.checked = true;
我希望你想用javascript和HTML动态创建复选框。你可以参考下面的链接
html - 使用JavaScript动态创建复选框? - 堆栈溢出 [ ^ ]
Hi All,
Could you help me how to create checkbox on html using Javascript .
I have Array Table as ElmArray ="H2O,SIO2,Ni,Fe,MGO,Al,CaO"
thanks
Yusran
var myDiv = document.getElementById("myDiv");
var checkbox = document.createElement("input");
checkbox.setAttribute("type", "checkbox");
checkbox.setAttribute("name", "dd");
checkbox.setAttribute("value", "ff");
checkbox.checked = true;
myDiv.appendChild(checkbox);
//do this after you append it
checkbox.checked = true;
Hi,
I hope you want to create the checkbox dynamically using javascript and HTML. you can refer the below link
html - Creating the checkbox dynamically using JavaScript? - Stack Overflow[^]
这篇关于使用Javascript在html上创建复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!