How do I use JQuery to add an event to a textbox when the user pushes enter? [closed]
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
开发者_运维知识库 Improve this questionAnd please don't submit the form when the user pushes enter on THAT SPECIFIC textbox.
Check enter key on keyup event,
$j("#idOfSpecificBox").bind("keyup",function(e1){
if(e1.keyCode==13){
return false;
}
});
Use the keypress event
Your textbox:
<input type="text" id="myText" />
Your script:
$("#myText").keypress(function(e) {
if(e.keyCode == 13) {
alert("pressed");
}
});
#("#id_textbox").keydown(function(event){
if(event.keyCode == 13){
//fire
}
}
will this work?
精彩评论