Inside the click handler (or any event handler), this will refer to this element, for example:
$("#content").delegate("a", "click", function() { alert($(this).attr("something"));
In this case, we use .delegate() because you said: “My web page is updated dynamically with ajax,” so just attach the handler to the parent element, which is not replaced via AJAX, and it will work for all elements that you add below ... in the above example, we bind to all the <a> elements, but just change the selector accordingly.
source share