Here's the scenario: I have a set of buttons that I want to bind to corresponding functions when clicked. The ids of these buttons are the same as the names of their corresponding functions. I could do this:
$("#kick").click(kick);
$("#push").click(push);
$("#shove").click(shove);
But I'm lazy and would like to do this more lazily (as is my nature). As the buttons are all contained in a block element, I'd like to do something like this:
$("#button_holder > span").each(function () {
var doThis = this.id;
$(this).click(doThis);
});
Except that doesn't work. Any suggestions?