<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>javascript 函数</title>
</head>
<body>
<p>点击这个按钮,来调用带参数的函数。</p>
<button onclick="myfunction('harry potter','wizard')">点击这里</button>
<script>
function myfunction(name, job) {
alert("welcome " + name + ", the " + job);
}
</script>
<p>本例调用的函数会执行一个计算,然后返回结果</p>
<p id="demo"></p>
<script type="text/javascript">
function myfunction(a, b) {
return a * b;
}
document.getelementbyid("demo").innerhtml = myfunction(4, 3);
</script>
</body>
</html>