我希望我的輸入操作在輸入鍵被按下,但我的代碼不起作用。輸入提交輸入命中
HTML:
<div>
<div class="chat" data-active="1">
<section class="chat_info">
<span class="name">
</span>
<div class="options">
<div class="minimize">_</div>
<div class="exit">X</div>
</div>
</section>
<section class="conversation">
</section>
<section class="message">
<input type="text" id="abc" size="10">
</section>
</div>
</div>
,這裏是我的腳本,但按下回車鍵時不工作:
$(document).on("keypress", ".message input", function(event){
var keycode = (event.keyCode ? event.keyCode : event.which);
if(keycode === 13) {
alert();
}
});
[該問題不在您顯示的代碼中](http://jsfiddle.net/XH24P/) – Ohgodwhy