ボタンのいずれかを選択してクリックしようとすると、(予想どおり) 1 回のクリックが発生することもあれば、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>
私のマウスが悪いのでしょうか?または、上記のロジックが悪い場合、誰かがそれを修正する方法を教えてもらえますか?