Ronal
Ronal

Reputation: 2243

Jquery function binding

Can I get a couple of good examples on how to bind 3 separate functions I've got going on?

Upvotes: 1

Views: 953

Answers (2)

mothmonsterman
mothmonsterman

Reputation: 2481

You could also just chain them:

$("#MyItemID").click(func1).click(func2).click(func3);

Upvotes: 1

Mutation Person
Mutation Person

Reputation: 30498

Create one function that calls all three and then bind to that function.

Or use an anonymous function:

$("#MyItemID").bind("click", function(){
  func1();
  func2();
  func3();
});

You can also use the shorthand event. So (e.g.) for click:

$("#MyItemID").click(function(){
  func1();
  func2();
  func3();
});

Upvotes: 4

Related Questions