3
I have always used the on with multiple events with the thought that it would simplify my code and make it easier to understand, but from time to time I came across several plugins using the on in a chained way.
Example with multiple events:
$('#foo').on('click , dblclick', function(e) {
if (e.type === 'click') {
console.log('click');
} else {
console.log('double click');
}
});
Chained example:
$('bar').on('click', function() {
console.log('click');
}).on('dblclick', function() {
console.log('double click');
});
Analytically, there is some advantage/disadvantage of one approach to another ? there is some case that would take a slower?