<head>
   <script type="text/javascript" src="customScript.js"></script>
    <link href="dist/css/bootstrap.min.css" rel="stylesheet">
    <script src="docs/assets/js/vendor/jquery.min.js"></script>
    <script src="dist/js/bootstrap.min.js"></script>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="img/facebookicn.png">

    <title>Facbook</title>


    <link href="dist/css/jumbotron.css" rel="stylesheet">
    <link href="dist/css/custom.css" rel="stylesheet">


</head>


//这在coustom.js文件中

$(document).ready(function(){
    $('[data-toggle="tooltip"]').tooltip();
});


//这是HTML格式

    <div class="col-md-6 txtfeild ">
  <a href="#" data-toggle="tooltip" data-placement="left" title="Hooray!"><input id="firstName" class="form-control" placeholder="First Name"  type="text" onblur="validateName()" ></a>
       </div>


我收到这样的错误
customScript.js:1未捕获的ReferenceError:未定义$
在customScript.js:1尝试了许多方法,但无法解决此错误

最佳答案

在导入customScript脚本之前,将触发jQuery。将导入行移到customScript导入上方。

<script src="docs/assets/js/vendor/jquery.min.js"></script>
<script type="text/javascript" src="customScript.js"></script>
<link href="dist/css/bootstrap.min.css" rel="stylesheet">

关于javascript - customScript.js:1未捕获的ReferenceError:未定义$,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/45269356/

10-09 17:35