jQuery.easing[jQuery.easing.def] is not a function

后端 未结 9 831
春和景丽
春和景丽 2020-12-25 13:12

I am getting below error when I look in the console:

jQuery.easing[jQuery.easing.def] is not a function

I am trying to make a slider on Wor

相关标签:
9条回答
  • 2020-12-25 13:39

    did you import the jQuery easing plugin? something like

      <script src="http://code.jquery.com/jquery.min.js"></script>
      <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js"></script>
    

    in your page?

    0 讨论(0)
  • 2020-12-25 13:41

    Are you importing the jQuery easing plugin? Or anything higher than 1.7.2?

    Then just remove that and use this:

    <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.js"></script>
    
    0 讨论(0)
  • 2020-12-25 13:45

    The problem is

    swing: function (x, t, b, c, d) {
        return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
    }
    

    jQuery in this function could not be equal to the jQuery, where jQuery.extend( jQuery.easing, has been applied.

    1. replace jQuery with $
    2. wrap code with

      (function($, undefined) {
        ...
      }) (jQuery);
      
    0 讨论(0)
  • 2020-12-25 13:45

    Put jquery.easing.1.3.js to head tag before using plugin or use document.ready

    0 讨论(0)
  • 2020-12-25 13:46

    To save everyone some time. Open your Jquery easing plugin file and wrap the code inside:

    $(document).ready(function() {
      Code goes here...
    });
    
    0 讨论(0)
  • 2020-12-25 13:51

    Don't declare the script on the header, call it through jQuery's .getScript() function when the document is fully loaded.

    Example:

    <script>
    $( document ).ready(function() {
        $.getScript('path_to_script/easing_script_name.js');
    });
    </script>
    

    The error is due to that jQuery is called before easing script it's fully loaded.

    0 讨论(0)
提交回复
热议问题