开发者

How do I use JQuery to add an event to a textbox when the user pushes enter? [closed]

开发者 https://www.devze.com 2023-01-27 18:41 出处:网络
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post.
Closed. This question needs details or clarity. It is not currently accepting answers.

Want to improve this question? Add details and clarify the problem by editing this post.

Closed 8 years ago.

开发者_运维知识库 Improve this question

And 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?

0

精彩评论

暂无评论...
验证码 换一张
取 消