input type = button 的onclick属性调用函数
调用js函数
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="https://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js"> </script> <script> function fas(){ alert(1); } </script> </head> <body> <input type="button" onclick = "fas()" value = "sdsdsd"> </body> </html>
JQuery调用
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="https://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js"> </script> <script> $(function(){ $("#test").click(function(){ alert(1); }); }); </script> </head> <body> <input id = "test" type="button" value = "sdsdsd"> //无onclick,隐含调用 </body> </html>