Igor Golodnitsky
Igor Golodnitsky

Reputation: 4566

Jquery bind several functions to one element

Strange, is there no possibility to put several binds in jquery, on one element?

$('input').click(clickfn).click(clickfn)

I am using 1.3.2

function clickme() { alert('click me') }

$('.click', mod).bind("brrr", clickme).bind("brrr", clickme)
                .click(function() { $('.click', mod).trigger("brrr"); });

This is not working also. Executes one time.

Upvotes: 1

Views: 5235

Answers (1)

obeattie
obeattie

Reputation: 3354

What you have there should work just fine… it does for me (also with jQuery 1.3.2). Try this:

$('input').click(function(ev){ alert('func 1'); }).click(function(ev){ alert('func 2'); });

When you click the input elements, you should see consecutive alerts appear. Perhaps you are returning false in the first function? This would stop event propagation, so the second handler wouldn't be fired.

As an aside, I see you're doing this to input elements, so you probably want to use the focus event instead of click.

Upvotes: 4

Related Questions