-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