List all javascript events wired up on a page using jquery
(function($) {
$.eventReport = function(selector, root) {
var s = [];
$(selector || '*', root).andSelf().each(function() {
var e = $.data(this, 'events');
if(!e) return;
s.push(this.tagName);
if(this.id) s.push('#', this.id);
if(this.className) s.push('.', this.className);
for(var p in e) s.push('n', p);
s.push('nn');
});
return s.join('');
}
$.fn.eventReport = function(selector) {
return $.eventReport(selector, this);
}
})(jQuery);
[@more@]// all events
alert($.eventReport());// just events on inputs
alert($.eventReport('input')); // just events assigned to this element
alert($.eventReport('#myelement')); // events assigned to inputs in this element
alert($.eventReport('input', '#myelement'));
alert($('#myelement').eventReport('input')); // same result// just events assigned to this element's children
alert($('#myelement').eventReport());
alert($.eventReport('*', '#myelement'); // same result
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25556693/viewspace-1048918/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- How To List All The Named Events Set For A Database [ID 436036.1]Database
- How To List All The Named Events Set For A Database (Doc ID 436036.1)Database
- Assign Shortcut key for ASP.Net Page Using JavascriptASP.NETJavaScript
- Web Page Marker Pen All In OneWeb
- Understanding Delegated JavaScript EventsJavaScript
- Simulating Mouse Events in JavaScriptJavaScript
- A example that using JQuery clonejQuery
- Script – List status of all submitted DBMS jobs(轉)MIT
- javascript document.allJavaScript
- All calls to Java have to go via JavaCalls. Sets up the stack frameJavaGo
- How to create the Gold gold using RGB color values All In OneGo
- JavaScript Compact Object All In OneJavaScriptObject
- [Javascript] Perform Set Operations using JavaScript Set MethodsJavaScriptORM
- ifeng code relax jquery main page phone Version2jQueryAI
- 解決 ALL MIRROR URLS ARE NOT USING FTP, HTTP[S] OR FILE 問題FTPHTTP
- JavaScript Promise Time Limit Function All In OneJavaScriptPromiseMITFunction
- JavaScript’s “this”: how it works, where it can trip you upJavaScript
- Statspack報告分析—第6部分: Wait Events - Complete listAI
- 重學 JavaScript API - Page Visibility APIJavaScriptAPI
- javascript裡的document.all用法收集JavaScript
- JavaScript 進位制轉換 All In OneJavaScript
- [Javascript] Find Items from the end of the JavaScript Array using at, findLast and findLastIndexJavaScriptASTIndex
- ncurses滑鼠事件:mousemask(),ALL_MOUSE_EVENTS,KEY_MOUSE,getmouse(),mouse_grafo(),wmouse_trafo()事件
- 在 Microsoft Dynamics NAV 2018 Setting Up and Using a Purchase Approval WorkflowROSAPP
- JavaScript測試jQueryJavaScriptjQuery
- JavaScript object array sort by string bug All In OneJavaScriptObject
- All mirror URLs are not using ftp, http[s] or file. Cannot find a valid baseurl for repo: baseFTPHTTP
- JavaScript Math.trunc vs Math.floor All In OneJavaScript
- custom event in javascript and jqueryJavaScriptjQuery
- Why is gam_server using up 100% of my CPU on Red Hat Enterprise Linux 4GAMServerLinux
- Wired:揭露新iPhone 12 Pro的原始成本iPhone
- oracle eventsOracle
- Dynamics 365 Web API Set Values of all Data Types using Web API in Dynamics CRM Through C#WebAPIC#
- JavaScript string charCodeAt() vs codePointAt() All In OneJavaScript
- JavaScript 和 jQuery 設計模式JavaScriptjQuery設計模式
- Flutter - 手寫體widgets之wired_elementsFlutter
- jQuery - jQuery $(document).ready() 和 JavaScript [removed]() 的比較jQueryJavaScriptREM
- javascript debut trick, using the throw to make a interrupt(breakpoint) in your programJavaScript