-6
我对使用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>
我只是初学者,但我设法得到一些基本知识。当我使用按钮时,我看不到任何反应。我使用Notepad ++和最新的jQuery版本。例如,当我从网站上下载相同的文件,我正在使用它来学习它,但如果我自己创建它,它不是。对不起,这个简单的问题,但它真的研磨我的齿轮。有任何想法吗?先谢谢你!
我试图代码[这里](https://jsfiddle.net/u2n1v0tq/)及其工作.. –
你在控制台中遇到什么错误? – j08691
@Swellar您不应在编辑中更改文件的路径。这本身可能是错误。 – j08691