jQuery---$衝突的解決方案

$衝突的解決方案

 

遇到其餘js文件也用$包裝了函數。能夠把jQuery放在後面,並釋放下$的控制權,也能夠換個字符替代原來的$,例如$$ 或者,jQueryhtml

 

    //jQuery釋放$的控制權
    $$ = $.noConflict();

 

<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <title>Title</title>

  <script src="itcast.js"></script>
  <script src="jquery-1.12.4.js"></script>

  <script>

    console.log($);

    //jQuery釋放$的控制權
    $$ = $.noConflict();

    // jQuery(function () {
    // });

    $$(function () {

    });



  </script>
</head>

<body>

</body>

</html>
相關文章
相關標籤/搜索