Bekki
Bekki

Reputation: 729

Stop mousedown function

I've got a mousedown function. How can I stop the function when the mouse is released?

   $('#manRun').mousedown(function(e3) {
        var manID = get_id(this);
        e3.preventDefault();
        $(document).on('mousemove.moveMan', function(e2) {
           runing(e2, runBtn, manID);
        });
    });

Upvotes: 1

Views: 102

Answers (1)

stevenw00
stevenw00

Reputation: 1156

Create another function for mouseup then unattach the handler.

$('#manRun').on('mouseup', function(e) {
    e.preventDefault();
    $(document).off('mousemove.moveMan');
});

Upvotes: 2

Related Questions