admin管理员组文章数量:1415099
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
3 Answers
Reset to default 3Find 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?
本文标签: javascriptFinding all js events associated with a HTML element using ChromeStack Overflow
版权声明:本文标题:javascript - Finding all js events associated with a HTML element using Chrome - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745182069a2646511.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论