admin管理员组文章数量:1201571
My code is below:
$('.summaryT').keypress(function(e){
if(e.which == 13){
callajax();
$(this).focusout();
}
});
As you can see on the code above, When a user presses the enter key first callajax()
is run(working fine). After that I want to focus out from the .summaryT
input box, How can I achieve this?
My code is below:
$('.summaryT').keypress(function(e){
if(e.which == 13){
callajax();
$(this).focusout();
}
});
As you can see on the code above, When a user presses the enter key first callajax()
is run(working fine). After that I want to focus out from the .summaryT
input box, How can I achieve this?
4 Answers
Reset to default 16Try this
$('.summaryT').keypress(function(e){
if(e.which == 13){
callajax();
$(this).blur();
}
});
Since AJAX stands for asynchronous, you may want to call focusout()
after the call successfully finished.
use the jquery blur() event
$('.summaryT').keypress(function(e){
if(e.which == 13){
callajax();
$(this).blur();
}
});
Here is the solution even if Mousetrap is activated
$('.selectorClass').keypress(function(e)
{
if(e.which == 13)
{
// 13 is a code to hit keyboard enter button
alert('Enter is pressed');
}
});
$('#selectorID').keypress(function(e)
{
if(e.which == 13)
{
// 13 is a code to hit keyboard enter button
alert('Enter is pressed');
}
});
本文标签: javascriptJquery focus out after pressing enter keyStack Overflow
版权声明:本文标题:javascript - Jquery focus out after pressing enter key - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738556636a2098419.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论