IE 9 jQuery error: “Object doesn't support … 'on'”?

前端 未结 2 1009
忘掉有多难
忘掉有多难 2021-01-13 03:46

I need help. I\'m getting the following error in IE9. The code is working in FireFox:

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


        
2条回答
  •  -上瘾入骨i
    2021-01-13 04:17

    One of two things is happening:

    1. $ is not jQuery, but a function defined elsewhere; or,

    2. $ is not the correct version of jQuery. on was introduced in 1.7.


    For jQuery 1.6 the following on:

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

    can be written using delegate (since 1.4, deprecated 1.7):

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

    can be written using live (since 1.3, deprecated):

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

    Please refer to the documentation for more options and caveats.

    Using delegate can attach "below" the body (like on) where as live always attaches at the body level. Thus the above could possibly be written more efficiently, depending upon where the target is located.

    Happy coding.

提交回复
热议问题