0
点赞
收藏
分享

微信扫一扫

Golang容器:map

alonwang 2024-05-27 阅读 12

在JavaScript中,要禁用一个按钮的点击事件直到某个操作完成,你可以将其点击事件用匿名函数的方式书写。
你可以将其在点击函数内设置为null来禁用按钮。

   

<button id="butto_n">点击抽奖</button>
    <script>
    butto_n.onclick = butt;
     
    function butt() {
     
    //函数事件
     
    butto_n.onclick = null;
     
    }
     
    </script>

然后在你的函数事件完成后,将其在你想要重新启用的地方,重新调用:

  

 if ('事件完成') {
                        
    butto_n.onclick = butt;
                    
    }

如果你使用的是其他类型的异步操作(比如setTimeout或回调),你需要确保在异步操作完成后正确地重新启用按钮。

举报

相关推荐

Golang map

golang空map

map容器

Golang map 详解

golang学习-map

map容器实战

0 条评论