【发布时间】:2015-02-02 10:40:27
【问题描述】:
我正在 nodejs 中创建一个聊天应用程序。
在 index.html 文件中,我设置了用户发送消息的界面,我定义了以下形式:
<form id="chat-form" name="chat-form">
<input type="text" name="chat-input" id="chat-input" placeholder="type message">
<br>
<input type="submit" value="send"/>
</form>
在<head> </head> 标签内,我使用以下脚本:
$('#chat-form').submit(function(e){
console.log("inside the submit");
});
虽然预期此代码可以工作,但从未到达提交代码。
【问题讨论】:
-
把你的代码放在 document.ready 中,比如 $(document).ready(function(){ $('#chat-form').submit(function(e){ console.log("inside提交"); }); });
标签: javascript jquery forms