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

WBOY
WBOYOriginal
2016-05-16 17:44:441026browse

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]