我把代码改成这样 ,该怎么调用函数呢
如题,当我定义了一个sub2函数,该怎么调用呢
2015-08-26
<!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) //定义函数
{
sub=a-b;
alert("a和b的差:"+sub);
}
</script>
</head>
<body>
<form>
<input type="button" value="点击我" onclick="sub2(5,2)" />
</form>
</body>
</html>
<!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) //定义函数
{
sub=a-b;
alert("a和b的差:"+sub);
}
</script>
</head>
<body>
<form>
<input type="button" value="点击我" onclick="sub2(5,2)" />
</form>
</body>
</html>
举报