The Poet The Poet - 2 years ago 75
Javascript Question

How to access the current element in a selector?

I want to avoid the overhead of calling

again and wanted to reference the element that is already selected in the selector, something like using

any help?

$("#aModel1").click(function () {
alert( ??? .attr("myattribute") );

Answer Source

jQuery $(this) will do it

$("#aModel1").click(function () {
    alert( $(this).attr("myattribute")  );
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download