【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 編輯過 |
關鍵字查詢
相關文章
正在查詢... |