IE 9 jQuery Error: "Object does not support ... 'on'"?

I need help. I get the following error in IE9. The code works in FireFox:

SCRIPT438: Object doesn't support property or method 'on' 

This is expressed in the following code:

$(function() {
    $(document).on('change', '#dropdownval select', function(event) {
        //logic function
    });
});
+5
source share
2 answers

Works in Firefox, but not in IE?

I would make sure that both browsers load the same source. Honestly, you cannot use it for Firefox .onwhen using jQuery 1.6, since the method does not exist.

In your console (F12 Developer Tools in IE and Firebug in Firefox), enter the following:

jQuery.fn.jquery

jQuery, . , StackOverflow "1.7.1". -, .on, , , :

!!jQuery.fn.on // True if .on is present, False otherwise

jQuery 1.6 .delegate, .on

jQuery 1.6, .on, jQuery 1.7. .delegate, jQuery (Microsoft CDN, Google CDN, jQuery CDN).

.delegate .on :

$("#dropdownval").delegate("select", "change", function(event){
    alert( $(this).val() );
});

Fiddle: http://jsfiddle.net/jonathansampson/rMBn4/

...

.on, , document object - , , . , .delegate, - select:

$("#dropdownval").on("change", "select", function(event){
    alert( $(this).val() );
});

Fiddle: http://jsfiddle.net/jonathansampson/rMBn4/1/

, - . .delegate . .on .

+10

:

  • $ jQuery, , ; ,

  • $ jQuery. on 1.7.


jQuery 1.6 on:

$(document).on('change', '#dropdownval select', ...)

delegate ( 1.4, 1.7):

$(document).delegate('#dropdownval select', 'change', ...)

live ( 1.3, ):

$('#dropdownval select').live('change', ...) 

, .

delegate, "" (, on), live . , , , .

.

+7

All Articles