我不明白爲什麼它不工作...玉按鈕和jQuery單擊事件
我有這個index.jade文件:
!!! 5
html
head
link(rel='stylesheet', href='/stylesheets/style.css')
script(src="/javascripts/jquery-1.8.2.js")
script
$("#rollButton").click(function() {
alert("sas");
});
body
input#rollButton(type="button", value="Roll")
應該彈出警報!我錯過了什麼?
生成的HTML看起來不錯:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="/stylesheets/style.css">
<script src="/javascripts/jquery-1.8.2.js"></script>
<script src="/socket.io/socket.io.js"></script>
<script>
$("#rollButton").click(function() {
alert("sas");
});
</script>
</head>
<body>
<input id="rollButton" type="button" value="Roll">
</body>
</html>
只是查看生成的頁面源?答案應該是顯而易見的 –
你的腳本縮進是錯誤的 – supernova
btw如果你不想瘋了我只會把HTML放在翡翠中,需要你的腳本在那裏,並在另一個文件中寫入你的JavaScript代碼。 – supernova