简体   繁体   中英

TypeError: jQuery(…).on is not a function

Guys I have this function from a wordpress plugin:

jQuery( '#widget-twitter-__i__-username' ).on( 'change', function() {
  jQuery('#widget-twitter-__i__-list' ).val(0);
});

jQuery( '#widget-twitter-__i__-list' ).on( 'change', function() {
  jQuery('#widget-twitter-__i__-username' ).val(0);
});

The error I am getting is:

TypeError: jQuery(...).on is not a function

When I click that error on the error console, I get to the above code.

And I was wondering what would be the way to address this issue.

If your jQuery version is under 1.7 i'd suggest using .delegate() or .live() or update your jQuery to the latest version

jQuery( '#widget-twitter-__i__-list' ).delegate(

or

jQuery( '#widget-twitter-__i__-list' ).live(

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM