In this case:
$('body').on('click', '.a, .b, .c', function(e) {
...
How will I know when the click came from .a or .c for example?
In this case:
$('body').on('click', '.a, .b, .c', function(e) {
...
How will I know when the click came from .a or .c for example?
Within this event handler you can use this
. this
is the delegated element. To know if a given element has a class you can use el.classList
.
Take a look here ( link ), this example:
$('body').on('click', '.a, .b, .c', function (e) {
console.log(this, this.classList);
});
So to know if it's the element with the class a
you can do
if(this.classList.contains('a')){
// fazer algo
}