JS函数 函数调用 函数定义好后,是不能自动执行的,需要调用它,直接在需要的位置写函数名。
函数调用
任务
补充右边编辑器第15行,实现如下功能:
网页中有一按钮(名字"点点我"),当点击按钮后调用函数tcon(),弹出对话框"恭喜你学会函数调用了!"。
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>函数调用</title> <script type="text/javascript"> function tcon() { alert("恭喜你学会函数调用了!"); } </script> </head> <body> <form> <input type="button" value="点点我" onclick="tcon()"> </form> </body> </html>