What is a good yui replacement for jquery.live

浪尽此生 提交于 2019-12-12 16:15:34

问题


jQuery.live

Added in jQuery 1.3: Binds a handler to an event (like click) for all current - and future - matched element. Can also bind custom events.

http://docs.jquery.com/Events/live

Is there a good YUI replacement which can do this?


回答1:


In YUI3, delegates perform this function. The following snippet will fire a method called "clickHandler" on any 'p' tag in the body.

YUI().use('event', function(Y) {
  Y.delegate("click", clickHandler, "body", "p");
});

YUI 2.8.0 has delegate functionality as well, but the syntax is slightly different.



来源:https://stackoverflow.com/questions/1668804/what-is-a-good-yui-replacement-for-jquery-live

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!