Where does this reference to in a delegated .on event? Example:
$('#foo').on('click', $('.bar'), function() {
console.log(this);
});
In the example this will reference to #foo. But how do i access the bar element that got clicked? I might have 5 bar elements and I want to know which one was clicked.
Thanks
Edit: Sorry i changed #bar to .bar (since it exists multiple times).
The answer that i should just use '.bar' helped. But what if i have selector like this:
$('.bar').find('a');
How would i incorporate something like this?
This won't work: (cause this will reference to #foo)
$('#foo').on('click', $('.bar').find('a'), function() {
console.log(this);
});