Reputation: 1346
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?
Upvotes: 10
Views: 18423
Reputation: 179
$('.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');
}
});
Upvotes: 0
Reputation: 1115
use the jquery blur() event
$('.summaryT').keypress(function(e){
if(e.which == 13){
callajax();
$(this).blur();
}
});
Upvotes: 1
Reputation: 4081
Try this
$('.summaryT').keypress(function(e){
if(e.which == 13){
callajax();
$(this).blur();
}
});
Upvotes: 16
Reputation: 14365
Since AJAX stands for asynchronous, you may want to call focusout()
after the call successfully finished.
Upvotes: 1