I'm trying to write some jQuery to do the following: If a user clicks once on an object, do X.
If a user clicks twice on an object, do Y, but not X. I've been having some trouble with this as, obviously, a double-click will trigger the single-click twice. Here is a failed attempt: $('.todo_item h2').live('click', function() { var startTime = new Date(); $(this).mousedown(function() { var endTime = new Date(); if (Math.abs(endTime - startTime) < 300) { editInPlace } else { showExtra } }); }); where editInPlace and showExtra are some functions I have defined elsewhere in the document. This method, however, relies on a second click, or mousedown at least, to work, which fails if the user only clicks once. I have also looked into setTimeout but without any fruitful results. Anyone have any suggestions on how to code thsi?