jQuery implements the method of binding carriage return event to input

  • 2021-07-18 06:36:53
  • OfStack

This paper describes the method of binding carriage return event to input by jQuery. Share it for your reference, as follows:


<script type="text/javascript" src="Scripts/jquery-1.6.2.js"></script>
<script language="javascript" type="text/javascript">
$(function(){
    $('#dataInput').bind('keypress',function(event){
      if(event.keyCode == "13")
      {
        alert(' What you entered is: ' + $('#dataInput').val());
      }
    });// Method 2 As follows 
     $(document).keydown(function(e) {
     if (e.keyCode == 13) {
        //dologin();
     }
  });
});

For more readers interested in jQuery related content, please check the topics of this site: "Summary of Usage and Skills of Common Events of jQuery", "Summary of Common Plug-ins and Usage of jQuery", "Summary of Data Skills of jQuery Operation json", "Summary of Extension Skills of jQuery", "Summary of Drag and Drop Effects and Skills of jQuery", "Summary of Operation Skills of jQuery Table (table)", "Summary of Common Classic Special Effects of jQuery", "Summary of Animation and Special Effects Usage of jQuery" and "Summary of Usage of jquery Selector"

I hope this article is helpful to everyone's jQuery programming.


Related articles: