javascript - Finding all js events associated with a HTML element using Chrome - Stack Overflow

Is there a easy way to find all js events that are associated with a specific HTML element using Chrome

Is there a easy way to find all js events that are associated with a specific HTML element using Chrome?

Example:

HTML element

<a href="#" class="cancel_link refresh_page">Cancel</a>

Script:

<script type="text/javascript">
    $(function () {
       $(".cancel_link").click(function () {
          //do something
       });

       $(".refresh_page").click(function () {
          //do something
       });
    });

</script>

Is there a easy way to find all js events that are associated with a specific HTML element using Chrome?

Example:

HTML element

<a href="#" class="cancel_link refresh_page">Cancel</a>

Script:

<script type="text/javascript">
    $(function () {
       $(".cancel_link").click(function () {
          //do something
       });

       $(".refresh_page").click(function () {
          //do something
       });
    });

</script>
Share Improve this question asked May 21, 2014 at 0:02 Diego CotiniDiego Cotini 1,0692 gold badges18 silver badges27 bronze badges 1
  • Right-click element, Inspect Element, in Chrome Developer Tools, in the right pane you will see 'Styles', 'Computed', and 'Event Listeners'. That lists all events for an element. – webketje Commented May 21, 2014 at 0:06
Add a ment  | 

3 Answers 3

Reset to default 3

Find the html element in the Elements panel of the dev tools. Then click the Event Listeners tab in the right panel. In the top right hand corner of that Event Listeners panel there's a filter icon. When you click on it you can choose "All Nodes" (default) or "Selected Node Only".

  • Press F12 to open Developer Tools
  • Click the Elements tab
  • Select the element you with to analyze
  • On the right hand side click the Event Listeners tab

From that tab you can view all of the handlers bound to the element for each event.

Since you seem to use jquery, here is a previously posted solution:

// Bind up a couple of event handlers
​$("#foo").on({
    click: function(){ alert("Hello") },
    mouseout: function(){ alert("World") }
});​​​

// Lookup events for this particular Element
​$._data( $("#foo")[0], "events" );

you can find out more here: Can I find events bound on an element with jQuery?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745182069a4615464.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信