<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>定义函数</title> <script type="text/javascript"> function sub2(a,b) { var aaa = a-b; document.getElementById("sss").innerHTML+=aaa; } sub2(3,2); sub2(4,2); sub2(5,2); </script> </head> <body> <input type="button" value="点击我" onclick="sub2()" /> <div id="sss"></div> </body> </html>
肯定是NaN啊,你在点击事件中 都没有传参数,那怎么运算