jQuery: Call function periodically while click is held
<p>When an element is clicked, I want to call a function every n seconds until the mouse button is released.</p>

<p>How should I do this?</p>

<p>EDIT:</p>

<pre><code>    var interval,
        i = 0;

    $("a").on("mousedown", function(){
           interval = setInterval(function(){ $(".results").append(i++); }, 250);
    });

    $(document.body).on("mouseup", function(){
           clearInterval(interval)
    });​
</code></pre>
