So I know that we can have multiple event handlers on the .on() method
$(document).on({
'click': function (e) {
// function
},
'hover': function (e) {
// function
}
});
but is there anyway we can add multiple selectors to each event handler?
like this:
$(document).on('click', '#foo, .foo', function () {
// function
});
but with multiple .on() methods:
$(document).on({
'click', '#foo': function (e) {
// doesn't work :(
},
'hover', '.foo': function (e) {
// doesn't work :(
}
});
Thanks in advance
on- it will be far more maintainableon()methods or in case you need common selector then use selector as second argument