/ Published in: JavaScript
                    
                                        
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.
                This shows how you can just create a single function and in the event handler callback just call that function.
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
$('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');
}
Comments
 Subscribe to comments
                    Subscribe to comments
                
                