【发布时间】:2013-10-11 06:53:52
【问题描述】:
这段代码可以在javascript中变成循环吗? 感谢您帮助我学习 javascript!
html:
<div class="uploadBox"><input id="files3" class="upload" style="position:absolute;" placeholder="Upload Photo"/><input type="file" style="position:absolute;width:200px;height:44px;opacity:0;" id="selector3"/></div>
<div id="checkBox3" class="checkBox"><img src="images/check.png"></div>
javascript:
document.getElementById("selector1").addEventListener("change",function(){
document.getElementById("files1").value=
document.getElementById("selector1").files[0].name;
$('#checkBox1').css({'display': 'block'});
});
document.getElementById("selector2").addEventListener("change",function(){
document.getElementById("files2").value=
document.getElementById("selector2").files[0].name;
$('#checkBox2').css({'display': 'block'});
});
document.getElementById("selector3").addEventListener("change",function(){
document.getElementById("files3").value=
document.getElementById("selector3").files[0].name;
$('#checkBox3').css({'display': 'block'});
});
【问题讨论】:
-
我们还需要查看您的 html 代码。您的代码中有 jQuery,jQUery 也有一个
.each()方法... -
@Sergio 我添加了我的 html!感谢回复
-
这 2 个 div 是否有父 div?
标签: javascript loops foreach jquery