Copy code The code is as follows: <br>$(function () { <br>$('input:text:first').focus(); //Put focus on the first text box<br>var $inp = $('input' ; 🎜> var key = e.which; //e.which is the value of the key<br> if (key == 13) {<br> alert("aaa");<br> }<br>}); <br>});<br><br><br> </div>A strange phenomenon: <p>I dragged a Login control and then converted it into a template for custom development. <br><br><br><br><img src="http://files.jb51.net/file_images/article/201405/20140511111529.png" alt="Jquery monitors keys and presses the Enter key to trigger the implementation code of a method_jquery" ><br> <br>The above code captures the Enter button in the text field. At this time, the LoginButton needs to be triggered to submit the login information for verification. However, use $("[id$=LoginButton]").click(); only on firefox. It works, but it doesn't work in IE. Try $("[id$=LoginButton]").focus();, it works in IE. On IE, focus() completes the focusing and clicks. Why? Woolen cloth? </p> <p></p> <p></p> <div class="codetitle"><span>Copy code<a style="CURSOR: pointer" data="61772" class="copybut" id="copybut61772" onclick="doCopy('code61772')"><u></u> The code is as follows:</a></span></div>$inp.keypress(function (event) {<div class="codebody" id="code61772"> var key = event.which;<br> if (key == 13) {<br> $("[id$=LoginButton]").click(); //Support firefox, IE martial arts school<br> / /$('input:last').focus();<br> $("[id$=LoginButton]").focus(); //Supports IE, firefox is invalid. <br>//The above two sentences are implemented. Supports both IE and firefox<br> }<br>});<br><br><br> </div>Using keyboard listening events (ssh) in Jquery <p></p> <p></p> <div class="codetitle"><span>Copy code<a style="CURSOR: pointer" data="39746" class="copybut" id="copybut39746" onclick="doCopy('code39746')"><u></u> The code is as follows:</a></span></div>$(document).ready(function(){<div class="codebody" id="code39746"> find();<br>$("#pageSize").bind("keyup",function(){find();});<br> //Set the keyboard listening event, that is, when you enter the text After entering the value in the box, the corresponding method will be executed immediately. What it means here is that when you enter 4 in the text box, 4 pieces of data will be displayed on the page <br> ("#pageSize: This is to get the tag attribute id value)<br> ("keyup": the keyboard listening event value is fixed and cannot be changed)<br> (The following function(){find();}: is the method to be executed)<br>$( "#pageNo").bind("keyup",function(){find();});<br> //Set the keyboard listening event, that is, when you enter a value in the text box, the corresponding function will be executed immediately What the method means here is that when you enter 5 in the text box, the fifth page will be displayed on the page <br> alert(" find()");<br>Same as above<br> });<br> <br><br> </div>