gpt4 book ai didi

javascript - 如何在固定的时间内使用javascript函数?

转载 作者:行者123 更新时间:2023-12-02 14:57:33 25 4
gpt4 key购买 nike

<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");
}
}

关于javascript - 如何在固定的时间内使用javascript函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35681632/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com