Uncaught TypeError:Object[object object] has no method 'on'

前端 未结 3 709
生来不讨喜
生来不讨喜 2021-01-22 17:09

I m going to try this: http://jquerytools.org/demos/scrollable/index.html
But without any event trigger, I m getting below error

相关标签:
3条回答
  • 2021-01-22 17:45

    You need to update jQuery version.

    Because jQuery 1.6 does not have .on() it's added into new version of jQuery.

    0 讨论(0)
  • 2021-01-22 17:48

    JQuery .on method was added in 1.7. You need to update your JQuery as from your screenshot you are currently using 1.6

    http://api.jquery.com/on/

    Once downloaded from here, change the below where marked

    <head>
    <link href="css/scrollable-horizontal.css" rel="stylesheet" type="text/css" />
    <link href="css/scrollable-buttons.css" rel="stylesheet" type="text/css" />
    <script src="js/jquery-1.6.1.min.js"></script> <!-- Change this line -->
    <script src="js/jquery.tools.min.js"></script>
    </head>  
    
    0 讨论(0)
  • 2021-01-22 17:56

    You are using jQuery 1.6.1 - on() didn't exist back then (not until 1.7).

    Your options:

    • Either you use bind() instead.

    • Or you update to the latest jQuery.

    In regard to the second option, replace

    <script src="js/jquery-1.6.1.min.js"></script>
    

    with

    <script src="http://code.jquery.com/jquery-latest.min.js"
            type="text/javascript"></script>
    
    0 讨论(0)
提交回复
热议问题