How to make a jquery click event fire only on first click

Use .one():

$('.navbar1').one('click', function(e) {

It unbinds the click event once you trigger it.

If you don’t want an element to be double-clicked, something like this should work:

$(document).on('click', '.navbar1:not(.clicked)', function() {
    // ...
});

To make .navbar1 unclickable, just run $('.navbar1').addClass('clicked'). To make it clickable, do the opposite.

Leave a Comment