<img src='plus.jpg' width='80' height='80' onclick="myFunction2()">
返回
function myFunction2() {
var x = document.createElement("INPUT");
x.setAttribute("name", "image[]");
x.setAttribute("type", "file");
document.getElementById("add").appendChild(x);
}
我只想使用myFunction2()4次。之后,我要停止此功能。你能给我什么建议吗?提前致谢。
试试这个 :
var limit = 1;
function myFunction2() {
if(limit <= 4){
var x = document.createElement("INPUT");
x.setAttribute("name", "image[]");
x.setAttribute("type", "file");
document.getElementById("add").appendChild(x);
limit += 1;
}else{
alert("Stop");
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句