我不明白爲什麼這個jQuery腳本不起作用;jQuery單擊不工作,但jquery加載
$("#send").click(function() {
console.log("ee");
});
console.log("test");
當我加載頁面,我看到'測試'在控制檯,所以jQuery頁面加載。但是當我點擊#發現它沒有工作?
<!DOCTYPE html>
<html>
<head>
<title>Chat-o-matic</title>
<script src="//cdnjs.cloudflare.com/ajax/libs/socket.io/0.9.16/socket.io.min.js" type="text/javascript"></script>
<script src="//code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script>
<script src="chat.js" type="text/javascript" type="text/javascript"></script>
<link href="chat.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="container">
<h1>Chat-o-matic</h1>
<div id="round">
<p>Om de chat te joinen, typ een chatnaam in</p>
<input type="text" id="chatname" placeholder="Typ hier je chatnaam in...">
<button id="send">Join de chat</button>
</div>
</div>
</body>
</html>
那麼,有人知道爲什麼這不起作用,以及如何解決它?
您是否在[document-ready handler](http://api.jquery.com/ready/)中綁定了事件? – Satpal
不,只有一個。 請參閱HTML。 – DazDylz
[Simple jQuery click not working]可能的重複(http://stackoverflow.com/questions/8716655/simple-jquery-click-not-working) – undefined