The introduction of jquery appears: Uncaught ReferenceError: $ is not defined error

The introduction of jquery appears: Uncaught ReferenceError: $ is not defined error

Insert picture description here

The html code is as follows:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>

<body>
用户名:<input id="inputId" type="text" name="username" value="学编程"/>

<script type="text/javascript">
        //2:获取输入框架
        var $inputId = $("#inputId");
        // 3:获取value对应的值
        alert($inputId.val());
</script>
<script src="js/jquery-3.1.0.min.js"></script>
</body>
</html>

Check the browser network. Found that the introduction of jquery is successful, the status is 200

Insert picture description here

After consulting the relevant information, it was found that the order introduced by jquery was wrong

[External link image transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the image and upload it directly (img-HnX1kajK-1600308375472)( Insert picture description here
)]

Modified code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<script src="js/jquery-3.1.0.min.js"></script>
<body>
用户名:<input id="inputId" type="text" name="username" value="学编程"/>

<script type="text/javascript">
        //2:获取输入框架
        var $inputId = $("#inputId");
        // 3:获取value对应的值
        alert($inputId.val());
</script>

</body>
</html>

running result:

Insert picture description here

Guess you like

Origin blog.csdn.net/qq_37924905/article/details/108636758
Recommended