转 html给指定按钮添加回车事件

it2022-05-09  29

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=shift_jis" /> <script language="javascript"> function document.onkeydown() { if(event.keyCode == 13) { document.getElementById("enter").click(); return false; } } </script> </head> <body> <input type="button" id="enter" value="enter" οnclick="alert('enter');"/> <input type="button" value="123" οnclick="alert('123');" /> </body> </html> 

 

自:http://xiaojunwei1987.blog.163.com/blog/static/929126492009112231250606/

转载于:https://www.cnblogs.com/ijunxiong/articles/6831215.html


最新回复(0)