Chibuzo
Chibuzo

Reputation: 6117

Using .bind() vs simply calling the event

Please what is the difference between using jquery .bind() to attach an event to a selector and simply calling an event directly e.g .click() or .change()

Upvotes: 1

Views: 115

Answers (2)

Manse
Manse

Reputation: 38147

There is no difference between

$().click(fn) or $().change(fn)

and

$().bind('click',fn) or $().bind('change',fn)

as in the background (jQuery source) the click and change methods use bind

Although as pointed out in this answer -> jQuery: $().click(fn) vs. $().bind('click',fn);

You can use bind for multiple events

Upvotes: 3

alonisser
alonisser

Reputation: 12068

actually .click() .change() etc' are just a shorthand for using .bind() with bind you could bind multiple events, custom events, etc

Upvotes: 1

Related Questions