One click handler for multiple elements?
- by user246114
Hi,
I'm looking to add a click handler to a div. But is there a way to use a single click handler function and share it between multiple divs? Since I may have 100 divs, I don't want to create a click handler for each (they'll all practically do the same thing). The jquery example shows:
$("p").click(function () {
$(this).foo();
});
can we do something like:
$("p").click(myClickHandler);
function myClickHandler(source) {
source.foo();
}
?
Thanks