JS案例:通过函数统计商品的总价

来自CloudWiki
跳转至: 导航搜索
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>创建自定义函数示例</title>
<script type="text/javascript">
		function Totel(price,num){
		var totel=price*num;
		document.write("商品的总价为:"+totel);
		}
</script>
</head>
<body>
<script type="text/javascript">
		//调用函数时用实参代替形参
		Totel(2.3,5);	
</script>
</body>
</html>