Home >Web Front-end >JS Tutorial >Two implementation methods of js carriage return submission form_javascript skills

Two implementation methods of js carriage return submission form_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-05-16 17:44:441101browse

1. JavaScript method :

Copy code The code is as follows:

[javascript] <script> <BR>document.onkeydown=function(event){ <BR>e = event ? event :(window.event ? window.event : null); <BR>if(e.keyCode ==13){ <BR>//Execution method <BR>alert('Carriage return detected'); <BR>} <BR>} <BR></script>
<script> <BR>document.onkeydown=function(event){ <BR>e = event ? event :(window.event ? window.event : null); <BR>if(e.keyCode==13){ <BR>// Execution method <BR>alert('Carriage return detected'); <BR>} <BR>} <BR></script>

2. jQuery method :
Copy code The code is as follows:

[javascript] <script> <BR> $(document).ready(function(){ <BR>$("Control for pressing Enter").keydown(function(e){ <BR>var curKey = e.which; <BR>if(curKey = = 13){ <BR>$("#Enter event button control").click(); <BR>return false; <BR>} <BR>}); <BR>}); <BR>< /script> <BR></script>
Statement:
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