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 :/
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 :/
The on()
method is bound to $.fn
$
$.fn.on.apply(this, args);
I think your syntax is incorrect. use syntax like
$('el').on("click", function() {
alert( $( this ).text() );
});
$(this).text
, you could just write this.textContent
, though. It saves you a number of function calls –
Silvester 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
jQObject.trigger('myevent');
, but that still means you have to manually trigger the event, and rather defeats the point, imo –
Silvester © 2022 - 2024 — McMap. All rights reserved.