Say I have two click handlers which perform the same functionality :
$(\'#div1\').click(function(event) {
alert(\'here\');
});
$
Try this:
$('#div1, #div2').click(function(event) {
alert('here');
});
Furthermore, if you have a lot of div elements, contained in a common parent, you may take benefit of event delegation and attach a single handler to the parent itself, like so:
$('.common-parent').on('click', 'div', function(event) {
...
});