jQuery's .delegate() method is a great way to go if you don't want the overhead of hundreds of click events.
It assigns one event to a container, which gets fired when the specified descendants of the container get the event.
Test the example: http://jsfiddle.net/jYKgm/
HTML
<div id="container"> // #container has the event handler assigned
<div>content</div>
<div>content</div>
<div>content</div>
<div>content</div>
<div>content</div>
<div>content</div>
</div>
jQuery
// The click event handler will fire when <div> elements
// that descend from #container get clicked.
$('#container').delegate('div', 'click', function() {
alert('index ' + $(this).index() + ' was clicked');
});
This will assign one handler to the #container element, and make it so that any descendant div elements will trigger the handler.
So if there are 500 descendant div elements, they will all share the one event handler.
- .delegate() - http://api.jquery.com/delegate