复制代码 代码如下:
</pre><pre name="code" class="javascript"><html>
<body>
<input type="button" name="input[]" value="按钮1" /><br />
<input type="button" name="input[]" value="按钮2" /><br />
<input type="button" name="input[]" value="按钮3" /><br />
<div id="add"></div>
</body>
</html>
<script type="text/javascript">
// 通过 getElementsByTagName 获得都有 input 控件
var inputs =document.getElementsByTagName("input");
// 为第0个button绑定onclick事件,alert一下
inputs[0].onclick = function(){
alert("我测试一下");
}
// 为每一个button绑定onclick事件,alert一下
for(var i=0;i<inputs.length;i++){
inputs[i].onclick = function(){
alert("我测试一下");
}
}
window.onload = function(){
// 定义一个数组 arrs
var arrs = new Array();
// 循环添加
for(var i=0;i<2;i++){
// 循环添加两个 input type="button" value="新增"+i
var input = document.createElement("input");
input.type = "button";
input.value = "新增" + i;
// 记得把创建的 input 放入 arrs 中
arrs.push(input);
// 然后把 input 放入 id="add" 的div中
document.getElementById("add").appendChild(input);
}
// 同样用 [0].onclick 绑定事件,依然没有问题
arrs[0].onclick=function(){
alert("我又测试一下");
}
}
</script>
</pre><pre name="code" class="javascript"><html>
<body>
<input type="button" name="input[]" value="按钮1" /><br />
<input type="button" name="input[]" value="按钮2" /><br />
<input type="button" name="input[]" value="按钮3" /><br />
<div id="add"></div>
</body>
</html>
<script type="text/javascript">
// 通过 getElementsByTagName 获得都有 input 控件
var inputs =document.getElementsByTagName("input");
// 为第0个button绑定onclick事件,alert一下
inputs[0].onclick = function(){
alert("我测试一下");
}
// 为每一个button绑定onclick事件,alert一下
for(var i=0;i<inputs.length;i++){
inputs[i].onclick = function(){
alert("我测试一下");
}
}
window.onload = function(){
// 定义一个数组 arrs
var arrs = new Array();
// 循环添加
for(var i=0;i<2;i++){
// 循环添加两个 input type="button" value="新增"+i
var input = document.createElement("input");
input.type = "button";
input.value = "新增" + i;
// 记得把创建的 input 放入 arrs 中
arrs.push(input);
// 然后把 input 放入 id="add" 的div中
document.getElementById("add").appendChild(input);
}
// 同样用 [0].onclick 绑定事件,依然没有问题
arrs[0].onclick=function(){
alert("我又测试一下");
}
}
</script>
华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com
暂无评论...
更新日志
2024年09月23日
2024年09月23日
- Merryland《Merryland》[FLAC/分轨][170.22MB]
- 庄锭欣 ELKIE《没有你的未来》[320K/MP3][15.78MB]
- 庄锭欣 ELKIE《没有你的未来》[FLAC/分轨][36MB]
- TchaikovskySwanLake,Op.20柴可夫斯基天鹅湖(2013)SACD[Hi-Res]
- 24bit达人艺典《琴歌终极版》整轨WAV+CUE
- 黑鸭子.2005-《发烧DSD》柏菲[WAV分轨]
- 群星.1990-电影看板·人间道【宝丽金】【WAV+CUE】
- 周殷廷.2024-TO.WHOM.IT.MAY.CONCERN【环球】【FLAC分轨】
- 草蜢.1997-三人世界精选17首【宝丽金】【WAV+CUE】
- 【古琴音乐】管平湖《广陵散》2004[FLAC+CUE]
- 【中国民乐】《少数民族器乐·苗岭的早晨》2004[WAV+CUE]
- 【中国音乐】盛中国《新疆之春》2004[FLAC+CUE]
- 群星《音你而来 第8期》[320K/MP3][44.64MB]
- 群星《音你而来 第8期》[FLAC/分轨][121.21MB]
- 群星《十二女声Ⅲ》[WAV/CUE/分轨][626.4MB]