动态创建按钮的JavaScript代码
废话不多说了,直接给大家贴js代码了,具体代码如下所示:
<!doctypehtml>
<html>
<head>
<metacharset="UTF-8"/>
<title>Document</title>
<scripttype="text/javascript">
vari=0;
functionaddInput(){
varo=document.createElement('input');
o.type='button';
o.value='按钮'+i++;
if(o.attachEvent){
o.attachEvent('onclick',addInput)
}else{
o.addEventListener('click',addInput)
}
document.body.appendChild(o);
o=null;
}
</script>
</head>
<bodyonload="addInput()">
</body>
</html>
以上所述是小编给大家介绍的动态创建按钮的JavaScript代码,希望对大家有所帮助。
热门推荐
10 感谢韩语老师祝福语简短
11 升职文案高级祝福语简短
12 花童结婚祝福语大全简短
13 向国庆送祝福语简短
14 什么寄语简短祝福语女生
15 客户回礼祝福语大全简短
16 女孩生日祝福语简短创意
17 家长回复节日祝福语简短
18 给外婆敬酒祝福语简短