Return to Snippet

Revision: 44958
at April 21, 2011 06:11 by anagaiyahoocom


Initial Code
$('dt').find('a').click(doit);
		
function doit(e)
{
   //e - is event object passed in
   e.preventDefault();
   //this - is the element this func is attached to
   alert($(this).attr('href'); 
}

Initial URL

                                

Initial Description
Is very inefficient to attach a anonymous function event handlers to multiple items in a selection. The function is duplicated for each element. 

This shows how you can just create a single function and in the event handler callback just call that function.

Initial Title
Jquery Callback Without Anonymous Function

Initial Tags
jquery

Initial Language
JavaScript