overriding previously-bound click events

Posted by JamesBrownIsDead on Stack Overflow See other posts from Stack Overflow or by JamesBrownIsDead
Published on 2010-05-07T05:39:49Z Indexed on 2010/05/07 8:38 UTC
Read the original article Hit count: 300

Filed under:
|
|
|

When I use this code with an element whose id is "foobar":

$("#foobar").click(function () { alert("first"); });
$("#foobar").click(function () { alert("second"); });

I get two alerts: "first" and "second" second.

How do I specify a click event that also clears out any previous click events attached to the element? I want the last $("#foobar").click(...) to erase any previously bound events.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about JavaScript