[jQuery] Separate Functions for Events
Hi, I've just started using jQuery and have run into the following
problem that I'm sure has an easy answer.
I want a function to run after an event, for example, if I click on a
test div:
$("#test").click(function(){ $(this).css("color","pink") });
Instead of this, I want to have the effects of the click in a separate
function, like this:
$("#test").click(update_div)
jQuery.fn.update_div = function() {
this.css("color","pink");
};
I know the example is longer, but if I wanted to do more complex
stuff, I feel it would be better put in a separate function.
Is this possible?
thanks,
DAZ