Inclusion of more than two JQuery libraries creates problems

前端 未结 1 1348
盖世英雄少女心
盖世英雄少女心 2021-01-29 03:10

I am including these JQuery libraries:

src=\"JQuery/jquery-1.4.2.min.js\"
src=\"JQuery/jquery-ui-1.8.6.custom.min.js
src=\"JQuery/menu_login.js\"
src=\"GjQuery/         


        
相关标签:
1条回答
  • 2021-01-29 03:49

    What is the purpose behind including multiple versions of jQuery?

    If you can, use only 1 (newest hopefully) version.

    Alternatively, if each plugin you are using requires a different version, use NoConflict and make sure each plugin gets the correct version that it needs. You can also use closures and self invoking functions to still use $ like normal, while controlling which version you're using.

    <script src="http://code.jquery.com/jquery-1.4.2.js"></script>
    <!-- other scripts that depend on 1.4.2 --->
    <script>
    var $.1.4.2 = $.noConflict(true);
    </script>
    
    <script src="http://code.jquery.com/jquery-1.2.6.js"></script>
    <!-- other scripts that depend on 1.2.6 --->
    <script>
    var $.1.2.6 = $.noConflict(true);
    </script>
    
    <script>
    (function($){  
      // $ in here is jQuery 1.4.2 
    })($.1.4.2);
    
    (function($){
      // $ in here is jQuery 1.2.6 
    })($.1.2.6);
    </script>
    
    0 讨论(0)
提交回复
热议问题