jQuery $.on.apply not working

依然范特西╮ 提交于 2019-12-11 07:12:09

问题


Any one know why

$.on.apply(this, args);

gives me "Uncaught TypeError: Cannot read property 'apply' of undefined"

I know for sure that $.on is defined in jQuery :/


回答1:


The on() method is bound to $.fn $

$.fn.on.apply(this, args);



回答2:


I think your syntax is incorrect. use syntax like

$('el').on("click", function() {
       alert( $( this ).text() );
       });



回答3:


You know for sure $.on is defined, well... I beg to differ:

console.log($.on);//undefined
console.log($.fn.on);//function (a,c,d,e,f)
console.log($().on);//function...

Not sure though, that what you're trying to do is a valid use-case for jQuery's on, besides, applying the on function to a custom object doesn't give that object magical properties... I mean: it's not like that object will all of a sudden become clickable, if it's just an object literal



来源:https://stackoverflow.com/questions/27374391/jquery-on-apply-not-working

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