$.self() - Source element
There may be necessity to know the source element for a particular event inside the listener function. Imagine attaching a click event with same listener for 10 div elements and inside the listener we want to know exactly which div is clicked.
Returns
Example 1
Attaching a "click" event to 4 div elements with a listener. This listener changes border color only for the clicked div.
JS
HTML
CSS
$.domLoaded(function() { //Attach "click" event to div $.get("div").on("click", function() { $.self().style("border-color","blue"); }); });
Result
| |||||