Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个jquery函数!
当用户点击一个 div 时,该函数就会被执行!如果用户在 5 秒内单击 div,我不希望该函数再次执行。
这可能是什么解决方案?
帮助表示赞赏。谢谢!
一个简单的计时器会限制 5 秒的点击。见下文,
var isClickAllowed = true; $(element).click (function () { if (!isClickAllowed) return false; setTimeout(function () { isClickAllowed = true; }, 5000); isClickAllowed = false; });