Jquery bind several functions to one element

5.2k Views Asked by At

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.

1

There are 1 best solutions below

1
On BEST ANSWER

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.