$(".song").live('click', function songClick() {
//do stuff
});
Can you name a function like above and then call it at a later point? I tried, but it didn't work. Do I have to pass an event to it?
Note for reference's sake:
The live method was removed in version 9. Anyone coming across this question now should use on() instead. But otherwise, should work the same as above answers.
function songClick() {
//code
}
$(".song").on('Click', songClick);
If you only want the event handler to run once you can also use one() as well.