When an element is clicked, I want to call a function every n seconds until the mouse button is released.
How should I do this?
EDIT:
var interval,
i = 0;
$("a").on("mousedown", function(){
interval = setInterval(function(){ $(".results").append(i++); }, 250);
});
$(document.body).on("mouseup", function(){
clearInterval(interval)
});
Try this: http://jsfiddle.net/BDSUZ/