SyntaxStudy
Sign Up
Home jQuery Reference .off() / .one()

.off() / .one()

method

.off() removes event handlers; .one() attaches a handler that fires only once then auto-removes.

Syntax

$(selector).off(event) $(selector).one(event, handler)

Example

javascript
// Remove all click handlers
$('#btn').off('click');

// Remove named handler
$('#btn').off('click', myHandler);

// Fire only once
$('#subscribe').one('click', function() {
    $(this).text('Subscribed!').prop('disabled', true);
});