jQuery在记事本++上不起作用



我对用jQuery进行简单练习几乎没有问题。代码很短,所以我将整个内容放在这里:

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>fast exercise</title>
    <script scr="jquery.js"></script>
    <script>
        $(document).ready(function(){
            $("#btn1").click(function(){
                $("#main").text("The width of the element is " + $("#main").width() +"px and height is " + $("#main").height() + "px.")
            });
        });
    </script>
    <style>
        #main {
            width: 300px;
            height: 300px;
            background: red;
            color: black;
            padding: 30px;
            border: 2px solid black;
            margin: 5px;
        }
    </style>
</head>
    <body>
        <button id="btn1">Click here to see basic measurements</button>
        <div id="main">
            <p>This is div called "main"</p>
        </div>
    </body>
</html>

我只是初学者,但我设法获得了一些基础知识。当我使用按钮时,我没有看到反应。我使用记事本 和最新的jQuery版本。例如,当我从网站上下载同一文件时,我用来学习它有效,但是如果我自己创建它,则不是。抱歉,这很简单,但确实使我的装备磨碎了。有任何想法吗?预先感谢您!

它是您的script标签中的错字,更改scr

<script scr="jquery.js"></script>

src

<script src="jquery.js"></script>

最新更新