动态创建按钮的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代码,希望对大家有所帮助。
热门推荐
6 保研的祝福语简短
10 年轻20岁祝福语简短
11 朋友结婚祝福语信息简短
12 女孩婚礼贺卡祝福语简短
13 30段点歌简短祝福语
14 虎年春节祝福语图文简短
15 写给后妈祝福语大全简短
16 简短回复生日祝福语
17 校长送毕业祝福语简短
18 毕业立体贺卡祝福语简短