Can't get one click on the mouse using jquery?
When I attempt to click on any one selection on of the buttons, sometimes
I get one click (as expected) and sometimes I get more than one click
fired (not what I want) using the code below given by someone on
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);
Could be my mouse is bad? Or the logic above is bad, and if so, can
someone show me how to fix it?
No comments:
Post a Comment