这段代码可以在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'});
});