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

  • SEARCH
  • Home
  • 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 6090727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:14:49+00:00 2026-05-23T12:14:49+00:00

Let, <span onclick=foo() onfocus=goo()>Have Event</span> Here I give this just for example. Here with

  • 0

Let,

<span onclick="foo()" onfocus="goo()">Have Event</span>

Here I give this just for example. Here with the span two events have bind.

Is there any javascript or jquery way to find out all events bind with any html element?

  • 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-23T12:14:50+00:00Added an answer on May 23, 2026 at 12:14 pm

    You can’t with DOM2-style event handlers (ones added with addEventListener / attachEvent), which pretty much means you don’t want to be doing this as DOM2+ handlers are increasingly The Way It Shall Be Done(tm).

    The ones you’ve shown in your example are DOM0 event handlers, though, which you can check for: You can loop through the properties on the element, looking at the ones starting with “on”, and see whether they have a value:

    var element = document.getElementById("theSpan");
    var name;
    for (name in element) {
        if (name.substring(0, 2) === "on" && element[name]) {
            // It has a DOM0 handler for the event named by `name`
        }
    }
    

    Update:

    Apparently, at least on Chrome, the onXyz properties are non-enumerable so they don’t show up in for..in loops. And on Firefox, you only see the ones assigned programmatically, not via attributes.

    So, you can test them explicitly:

    if (element.onclick) {
        // It has a DOM0-style `click` handler
    }
    

    …but you’ll have to have a list of the ones you want to know about.

    Here’s an example (live copy):

    HTML:

    <p id="thePara" onclick="foo()">This is the paragraph</p>
    <script>
      // Some other bit of code setting a DOM0 handler programmatically
      document.getElementById("thePara").onmousedown = function() {
        display("<code>onmousedown</code> called for thePara");
      };
    </script>
    

    JavaScript:

    window.onload = function() {
      // Look up all handlers on thePara
      var element = document.getElementById("thePara");
      var name;
      var names = "onclick onmousedown onchange onmouseup".split(" ");
      var index;
    
      for (name in element) {
        if (name.substring(0, 2) === "on" && element[name]) {
          display("[loop check] thePara has handler for <code>" + name + "</code>");
        }
      }
    
      for (index = 0; index < names.length; ++index) {
        name = names[index];
        if (element[name]) {
          display("[explicit check] thePara has handler for <code>" + name + "</code>");
        }
      }
    };
    
    function display(msg) {
      var p = document.createElement('p');
      p.innerHTML = msg;
      document.body.appendChild(p);
    }
    
    function foo() {
      display("<code>foo</code> called");
    }
    

    Note again, though, that you probably don’t want to do this, as you’ll miss DOM2+ handlers.

    Also note that an event may be handled when you click an element even though that element doesn’t have an event handler for the event — because the event can bubble to the parent, which looks at the event.target, sees the relevant child, and takes appropriate action. This is how event delegation works, and it too is increasingly The Way It Shall Be Done(tm), so… 🙂

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

Sidebar

Related Questions

Can I have an identity (unique, non-repeating) column span multiple tables? For example, let's
Let's say we have the following html: <ul id=portfolio-list class=clearfix span-24> <li class=2012#foo bar
Let's say I have the following text: (example) <table> <tr> <td> <span>col1</span> </td> <td>col2</td>
Let's say I have this portion of HTML document: <div>hello world <span id=test></span></div> In
Okay, let's say you have something like this: <span class=image style=background-image: url('http://www.example.com/images/image1.png')></span> Every CSS
Let's say I do something stupid like this: <div class=my_class>fun wee!!</div> <span class=my_class><b class=my_class>Title</b></span>
Let's say I have this line somewhere in my code: <ul id=mobileBtnsBot> <li> <a
let's say I have this: link_to Profile, profile_path(@profile) # => <a href=/profiles/1>Profile</a> But if
Let's say I have this javascript: <script language=javascript type=text/javascript> function addtext() { var newtext
let's i have the following code http://jsfiddle.net/QhJWt/ <span contentEditable=true>asdfasdf </span> span { height:20px; width:100px;

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.