Get value of current event handler using jQuery

I can set the onclick handler using jQuery by calling


Also using jQuery, how can I get a reference to the function which is currently handling the click() event?

The reason is that I have another object and want to set its click handler to the same one as #id.


Thank you for all the suggestions. The problem is that I do not know which function is currently handling the clicks. Keeping track of it would add state to an already complicated template-editing system.



jQuery's .click(function) method adds the function to a queue that is executed on the click event~

So actually pulling out a reference to the given function would probably be hairy-er than you expect.

As noted by others, it would be better to pass in a reference to the function; and then you already have the reference you need.

var clicky = function () { /* do stuff */ };
// Do other stuff with clicky


If you really really need to get it out, try this:


Depending on your version of jQuery that may or may not work~ Try playing around with


and see what you get.

Got the idea from this section of the source:


if you dont know the name of the function you can use


function clickHandle(e){
  if($( == $('#id')) {
  $(newTarget).bind('click',  clickHandle);


I think this would be the most symantic way of going about it


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.