Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6103793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:46:09+00:00 2026-05-23T13:46:09+00:00

If I attach a click event handler: $(.selector).bind(click, function () { // some handler

  • 0

If I attach a click event handler:

$(".selector").bind("click", function () {
  // some handler function
});

How can I get a reference to that function? This doesn’t work:

var refToFunc = $(".selector").bind("click");
typeof refToFunc === "object";  // I want the function

I think bind("eventname") in that case just returns the jQuery object and not the event handler function. It must be stored somewhere.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:46:09+00:00Added an answer on May 23, 2026 at 1:46 pm

    Very interesting question. You can retrieve it like this:

    var refToFunc = $(".selector").data("events")["click"][0].handler;
    

    Note that we used [0] because you have an array of handlers, in case you bound more than one handler. For other events, just change to the event name.

    EDIT
    In general, you could use the following plugin to get all handlers of the selected elements for an event (code not optimized yet):

    $.fn.getEventHandlers = function(eventName){
      var handlers = [];
      this.each(function(){
         $.each($(this).data("events")[eventName], function(i, elem){
             handlers.push(elem.handler);    
         });     
      });
      return handlers;
    };
    

    How to use it?:

    $(".selector").getEventHandlers("click");
    

    And it would return an array of functions containing all event handlers.

    For your specific question, you could use this plugin like this:

    var refToFunc = $(".selector").getEventHandlers("click")[0];
    

    Hope this helps. cheers

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I attach a click event handler to an element inside an iframe?
I want to attach a 'click' event handler to the first child of an
I used jquery to attach a double click event handler to a table and
How do I attach a handler to the click event of a link, which
I want to attach a click event handler to each and every (Button, Anchor,
Suppose I attach an blur function to an HTML input box like this: <input
I need to attach some javascript to the onchange event of the Zend_Form_Element. How
I'm trying to delegate a click event to a TR element that contains a
Issue: Attach a click event on a link on a page (say link to
I am trying to attach a click event to a check box using JavaScript.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.