我是新來的jQuery,目前閱讀jQuery的假人,並試圖執行本書的第一個例子:警告框不會彈出
<!DOCTYPE html PUBLIC 「-//W3C//DTD XHTML 1.0 Strict//EN」
「http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd」>
<html>
<head>
<title>My Test Page</title>
<script type="text/javascript" src="js/jquery-1.7.2.js">
$(document).ready(function(){
alert(jQuery(‘img’).attr(‘alt’));
});
</script>
</head>
<body>
<p>This is my test page.</p>
<img src= "images/home.gif" height="28" width="28" alt="This is a test
image.">
</body>
</html>
但在執行這個例子後,警報框不彈出。
可能'jQuery的1.7.2.js '在本地目錄中沒有加載或丟失。 – Bob
對'jQuery('img')。attr('alt'));'使用雙引號或單引號''而不是那些有趣的 –
我沒有注意到有趣的。 :) – Bob