【HTML】JavaScript利用input控件的回车事件实现内容提交操作
当前位置:点晴教程→知识管理交流
→『 技术文档交流 』
![]() ![]()
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8" /> 5 <title>回车提交</title> 6 </head> 7 <body> 8 <h2>回车提交</h2> 9 <input type="text" id="enterSubmit" value="回车提交" /> 10 11 <script type="text/javascript"> 12 window.onload=function(){ 13 document.getElementById("enterSubmit").onkeyup=function(e){ 14 e=e||window.event;//获取事件对象 15 var keycode=e.keyCode||e.which||e.charCode;//获取键码 16 if(keycode===13){ 17 alert("回车提交成功"); 18 } 19 } 20 } 21 </script> 22 </body> 23 </html> 该文章在 2023/12/12 2:36:54 编辑过 |
关键字查询
相关文章
正在查询... |