2013-05-06 65 views
0

jQuery不能在我的HTML頁面上工作。可能有些代碼/語法問題。需要從一些好看的眼睛看。jQuery不能在我的HTML頁面上工作

<head> 
<script src="../common/js/jquery-1.9.0.js"/> 
<script> 
$(document).ready(function(){ 
    $("#insert").click(function(){ 
     alert("ok"); 
    }); 
}); 
</script> 
</head> 

<body> 
    <input type="submit" id="insert" value="Insert"/> 
</body> 
</html> 

我的文件在那裏我確定,但我的警報沒有彈出。請幫助

+3

'body'標籤在哪裏? – undefined 2013-05-06 07:45:36

+0

正在加載jquery文件 – Satpal 2013-05-06 07:46:17

+2

@undefined:'body'標記可以隱含在HTML5中。 [是的,真的。](http://www.w3.org/TR/html5/syntax.html#optional-tags)*(我不是說我認爲這是個好主意......)* – 2013-05-06 07:46:44

回答

6

script自關閉標籤,你需要刪除向前script開始標記結束凶多吉少。

變化

<script src="../common/js/jquery-1.9.0.js"/> 

<script src="../common/js/jquery-1.9.0.js"></script> 
+0

檢查更新後的答案。 – Adil 2013-05-06 07:48:05

+2

不客氣:) – 2013-05-06 07:48:42

+2

謝謝@Samuel Liew,你真好。 – Adil 2013-05-06 07:49:17

2

自行閉合的腳本標籤的將無法工作 - 你需要這個 -

<script src="../common/js/jquery-1.9.0.js"></script> 
3

更改此<script src="../common/js/jquery-1.9.0.js"/>

對此:<script src="../common/js/jquery-1.9.0.js"></script>

相關問題