Home > Web Front-end > JS Tutorial > body text

js and jquery carriage return submission method_javascript skills

WBOY
Release: 2016-05-16 16:16:13
Original
1166 people have browsed it

The example in this article describes the carriage return submission method of js and jquery. Share it with everyone for your reference. The details are as follows:

1. JavaScript method:

<script> 
  document.onkeydown=function(event){ 
    e = event &#63; event :(window.event &#63; window.event : null); 
    if(e.keyCode==13){ 
      //执行的方法 
      alert('回车检测到了'); 
    } 
  } 
</script> 
<script>
 document.onkeydown=function(event){
 e = event &#63; event :(window.event &#63; window.event : null);
 if(e.keyCode==13){
  //执行的方法
  alert('回车检测到了');
 }
 }
</script>
Copy after login

2. jQuery method:

<script> 
  $(document).ready(function(){ 
    $("按下回车的控件").keydown(function(e){ 
      var curKey = e.which; 
      if(curKey == 13){ 
        $("#回车事件按钮控件").click(); 
        return false; 
      } 
    }); 
  }); 
</script>
Copy after login

I hope this article will be helpful to everyone’s JavaScript programming design.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template