【发布时间】:2012-12-24 11:19:15
【问题描述】:
我正在使用 mysql 和 php 开发回复功能。
我的 MySQL 数据库:
reply:
rid - id;
topicid - under which topic;
uid - id of the guy who replies;
content - what did the guy said.
这是我的 html 代码:
<form id="replyform">
<textarea name="rplcont" placeholder="Press enter to submit your reply."><textarea>
</form>
我的问题是:我怎么知道是否按下了输入按钮?
非常感谢。
/------------------------------------------ ---/
这是我的有效代码:
html:
<textarea id="reply" name="reply" onKeyPress="enterpressalert(event, this)"></textarea>
js:
function enterpressalert(e, textarea){
var code = (e.keyCode ? e.keyCode : e.which);
if(code == 13) { //Enter keycode
alert('enter press');
}
}
它有效。
感谢所有关注这个话题的人!
【问题讨论】:
-
您可以在这里找到相关信息:stackoverflow.com/questions/239082/…
-
@VishalSuthar:谢谢,你真的很慷慨。我现在正在读..
-
if(code == 13) { alert('你按了 Enter,倒霉的数字!') }
标签: javascript enter