custom event in javascript and jquery
2014-05-02 08:53
549 查看
javascript:
jQuery
reference:
// add a eventListener document.addEventListener("abc", function(){alert('this is abc handler'}, false); //fire event document.dispatchEvent(new CustomEvent("abc", { detail: { message: msg, time: new Date(), }, bubbles: true, cancelable: true }));
jQuery
$(document).on('abc',function(){alert('this is abc handler on document'}); $.event.trigger({ type: "abc", message: "Hello World!", time: new Date() });
reference:
How to Create Custom Events in JavaScript
http://www.sitepoint.com/javascript-custom-events/How to Create Custom Events in jQuery
http://www.sitepoint.com/jquery-custom-events/相关文章推荐
- custom event and dragdrop solution in javascript
- A web-scraping framework written in Javascript, using PhantomJS and jQuery pjscrape
- pjscrape: A web-scraping framework written in Javascript, using PhantomJS and jQuery
- The run order about Loaded event and OnApplyTemplate in custom control of Silverlight 2 beta 2
- javascript window.event.clientX in Firefox and cursor:pointer
- JavaScript ,Css and Jquery In OpenERP 7.0
- Code optimization and organization in Javascript / jQuery
- Understanding this, $(this), and event in a JQuery callback function
- [JavaScript]Event Object in FireFox and IE
- Get the content of an Iframe in Javascript – crossbrowser solution for both IE and Firefox
- Ajax(Asynchronous JavaScript and XML)在JQuery中的应用
- Base Conversion In PHP and javascript
- Creating Web Applications in JavaScript with Express.js and ejs
- jquery and event
- Building a WPF Sudoku Game: Part 4 - Building a Least Privilege Plug-in System and Even More Custom Controls
- [从jQuery看JavaScript]-匿名函数与闭包(Anonymous Function and Closure)
- javascript事件之:jQuery.event.add事件详解
- 【翻译字幕】The Technology History of "JavaScript and JQuery"
- bind/on in JavaScript, jQuery, Backbone, Underscore
- Professional JS(13.3.1Event Object in DOM/IE/Cross-Browser/UI&Focus&Mouse and Wheel event[half])