Jquery monitor button press the enter key to trigger the implementation code of a method


<script type="text/javascript">
$(function () {
$('input:text:first').focus(); //Focus on the first text box
var $inp = $('input'); //All the input elements
$inp.keypress(function (e) { //I'm going to call the event parameter of function, e, event, whatever, e is the event that happens in the IE window.
    var key = e.which; //E.w.hich is the value of the key
    if (key == 13) {
        alert("aaa");
    }
});
});

A strange phenomenon:

I dragged a Login control and converted it to a template for custom development.

The return button in the text bar is captured in the above code, and you need to trigger the LoginButton to submit the login information for verification, but you use $(“[id$=LoginButton]“).click(); Only available in firefox, not in IE, try $(“[id$=LoginButton]”). Focus (); , effective in ie, on ie focus() that is to complete the focus and execute the click, why?

$inp.keypress(function (event) {
    var key = event.which;
    if (key == 13) {
        $("[id$=LoginButton]").click(); //Support firefox,IE martial arts school
        //$('input:last').focus();
        $("[id$=LoginButton]").focus();  //Support for IE, firefox not valid.
//Both IE and firefox are supported
    }
});

Jquery USES the keyboard to listen for events (SSH)

$(document).ready(function(){
  find();
$("#pageSize").bind("keyup",function(){find();});
    //Set the keyboard monitor event which is when you enter a value in the textbox and then immediately execute the corresponding method and what I'm showing you here is that when you type 4 and so on in the textbox it will display 4 pieces of data on the page
    ( "#pageSize : this is to get the label property id The value of the)
    ("keyup":  Keyboard monitor event   The values are fixed   Can't be changed )
    (at the back of the function(){find();} : is the method to be executed.)
$("#pageNo").bind("keyup",function(){find();});
   //Set the keyboard monitor event which is when you enter a value in the textbox you immediately execute the corresponding method and what I'm showing you here is that when you type 5 and so on in the textbox it will display the fifth page on the page
   alert(" find()");
 Same as above
   });