jQuery 文档翻译 .on()
2015-03-19 16:41
274 查看
.on( events [, selector ] [, data ], handler )
Description: Attach an event handler function for one or more events to the selected elements.绑定一个事件处理函数到选定元素
The
.on()method attaches event handlers to the currently selected set of elements in the jQuery object. As of jQuery 1.7, the
.on()method provides all functionality required for attaching event handlers. For help in converting from older jQuery event methods, see
.bind(),
.delegate(), and
.live(). To remove events bound with
.on(), see
.off(). To attach an event that runs only once and then removes itself, see
.one()
.on()方法将事件处理函数绑定到当前选定的一系列元素上。
Event names and namespaces
Any event names can be used for theeventsargument. jQuery will pass through the browser's standard JavaScript event types, calling the
handlerfunction when the browser generates events due to user actions such as
click. In addition, the
.trigger()method can trigger both standard browser event names and custom event names to call attached handlers. Event names should only contain alphanumerics, underscore, and colon chraracters.
事件名称和命名空间
events参数可以是任意事件的名称。当浏览器由于用户操作产生事件时,jQuery将调用handler函数。
$( "p" ).on( "click", function() { alert( $( this ).text() ); });
function myHandler( event ) { alert( event.data.foo ); } $( "p" ).on( "click", { foo: "bar" }, myHandler );
相关文章推荐
- 翻译: jQuery1.4官方文档(转)
- jquery.fullCalendar官方文档翻译(一款小巧好用的日程管理日历, 可集成Google Calendar)
- jQuery EasyUI API 中文文档 - EasyLoader 加载器 (风流涕淌 翻译)
- jQuery 选择器的优化(从官方文档翻译过来的)
- ujquery.fancybox api开发文档中文翻译版
- jquery.fullCalendar官方文档翻译(一款小巧好用的日程管理日历, 可集成Google Calendar)
- jquery.fullCalendar官方文档翻译(一款小巧好用的日程管理日历, 可集成Google Calendar)
- jQueryAPI参考文档中文版翻译
- jQuery EasyUI API 中文文档 - 窗口(Window)(风流涕淌 (philoo.cnblogs.com) 翻译)
- [翻译]帮助文档-jQuery 选择器
- jquery.ui中文文档翻译----draggable
- jquery.fullCalendar官方文档翻译(一款小巧好用的日程管理日历, 可集成Google Calendar)
- jQuery EasyUI API 中文文档 - 链接按钮(LinkButton)(风流涕淌 翻译)
- jquery.fullCalendar官方文档翻译(一款小巧好用的日程管理日历, 可集成Google Calendar)
- jQuery.fullCalendar官方文档翻译(转)
- jQuery核心文档(翻译中)
- jquery.ui.draggable中文文档(原文翻译)
- jQueryAPI参考文档中文版翻译
- jquery FullCalendar 官方文档翻译
- jquery日历插件 FullCalendar -----官方文档翻译