当我尝试单击按钮上的任何一个选项时,有时我会单击一次(如预期的那样),有时我会使用 Stackoverflow 上某人给出的以下代码触发多次单击(不是我想要的)...
var $document = $(document);
var clickCount = 0;
var treeLogic = function (event) {
// unbind the element from the event handler
$document.off("click", "#file", treeLogic);
clickCount = clickCount + 1;
// for testing the number of clicks on each click of a button.
// sometimes it shows one click and sometimes it shows more than one click
// (not what I want).
// bind the element back to the event handler
$document.on("click", "#file", treeLogic);
};
$document.on("click", "#file", treeLogic);
HTML 代码
<input type='button' id='button'></input>
会不会是我的鼠标坏了?或者上面的逻辑不好,如果是这样,有人可以告诉我如何解决它吗?