【发布时间】:2012-11-13 15:47:58
【问题描述】:
在我的项目中,我正在尝试禁用 Enter 键并提供我自己的 Enter 键功能。(我还没有这样做)
以下功能正在运行,但每当我在 TextBox 字段中按 Enter 键时,内容将添加到 div(根据需要)以及 TextBox 字段中,请输入关键功能正在发生(我不想要)。如何停止输入键功能在TextBox 字段上运行?为了清楚理解,请参阅下面代码中的我的 cmets。
.aspx 文件(工作)
<asp:TextBox ID="msg" BackColor="Transparent" runat="server" BorderStyle="None"
TextMode="MultiLine" />
jQuery(工作)
$('#msg').keypress(function (e) {
if (e.which == 13) {
//Shows the TextBox text in a Div, which I want to.
chat.server.send($('#msg').val()); //also going one step down in TextBox field which I dont want to.
$('#msg').val(''); //Clearing the Text in TextBox field
//what should I add here to make the Enter Key work only for the DIV?
}
});
【问题讨论】:
-
是的,看看你问过的重复问题,就像其他一百万人一样......
-
@Ian
close在得到一个好的答案后会有什么好处? :) -
您应该在发布问题之前仔细检查。
-
@AbijeetPatro 在问这里之前我搜索了很多。我不知道
duplicate question的关键字是什么。顺便说一句,堆栈溢出是为了进行问答。我们应该在我们的帖子中展示我所做的研究,你可以清楚地看到。
标签: javascript jquery asp.net