I'm trying to adapt the code from this answer to a jQuery appended element, without using any "flag" variables.
Original code is :
$(window).mousedown(function(e) {
clearTimeout(this.downTimer);
this.downTimer = setTimeout(function() {
alert('mousedown > 2 sec');
}, 2000);
}).mouseup(function(e) {
clearTimeout(this.downTimer);
});
So I can't see how to use it with document
:
$(document).on('mousedown', '.item', function(){
// How to chain mouseup ?
});
I've tried with
$(document).find('.item')
but no luck.