rjg132234 rjg132234 - 1 year ago 78
jQuery Question

In jQuery, how do you add code to an already bound element?

I have an element (e.g

) and it has a binding on it in the source code.

$('#elm').on('touchstart', function(){ /* do stuff */ });

Now I am adding more code to the page and I want to add new functionality to the binding of the element, WITHOUT removing the previous
do stuff

How can I add code to the #elm

Answer Source
$('#elm').on('touchstart', function () { /* do stuff */ });
$('#elm').on('touchstart', function () { /* do other stuff */ });

Use as many event handlers as you like.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download