Nitin Nitin - 4 months ago 11
jQuery Question

What is the difference between .on('click tap') and .on('click || tap')?

What is the difference between

$('.classname').on('click tap', function(){});


and in the second case there is an OR sign ('||') between the events

$('.classname').on('click || tap', function(){});


Both seem to work fine but I would really like know if adding an OR sign in the second case makes a difference?

Answer

|| is not used as OR in jquery binding. It bind custom event named ||. Which can be triggered by:

$('.classname').trigger('||');

So, don't use it, if you don't need it.

Comments