由于该功能执行功能后如何禁用Enter/Return键? [英] How to disable Enter/Return Key After a function is executed because of it?
本文介绍了由于该功能执行功能后如何禁用Enter/Return键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有此功能,其中#text_comment是文本区域的ID:
I have this function where #text_comment is the ID of a textarea:
$('#text_comment').live('keypress',function (e) {
if(e.keyCode == 13) {
textbox = $(this);
text_value = $(textbox).val();
if(text_value.length > 0) {
$(this).prev().append('<div id="user_commenst">'+text_value+'</div>');
$(textbox).val("");
}
}
});
正在发生的事情是,当按下回车键或回车键(键代码13)时,文本将追加,但是它也将文本向下移动一行,这是按回车键所应该的.
What is happening is the text is appending when the enter/return key is hit (keyCode 13), but it is also moving the text a line down, as the enter/return key is supposed to.
即使我将文本框的值设置为",也会发生这种情况.
This is occurring even though I set the value of the textbox to "".
推荐答案
在此处回答 http://jsfiddle.net/Z9KMb /
这篇关于由于该功能执行功能后如何禁用Enter/Return键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文