2009-11-15 15:06:31| 分类: javascript | 标签: |举报 |字号大中小 订阅
0020:函数
如何调用函数。
<html>
<head>
<script type="text/javas
function myfunction()
{
alert("您好!")
}
</script>
</head>
<body>
<form>
<input type="button" on
</form>
<p>通过点击这个按钮,可以调用一个函数。该函数会提示一条消息。</p>
</body>
</html>
0021:带有参数的函数
如何向函数传递变量,以及如何在函数中使用该变量。
<html>
<head>
<script type="text/javas
function myfunction(txt)
{
alert(txt)
}
</script>
</head>
<body>
<form>
<input type="button" on
</form>
<p>通过点击这个按钮,可以调用一个带参数的函数。该函数会输出这个参数。</p>
</body>
</html>
0022:带有参数的函数 2
如何向函数传递多个变量,以及如何在函数中使用这些变量。
<html>
<head>
<script type="text/javas
function myfunction(txt)
{
alert(txt)
}
</script>
</head>
<body>
<form>
<input type="button"
on
value="在早晨">
<input type="button"
on
value="在夜晚">
</form>
<p>通过点击这个按钮,可以调用一个函数。该函数会输出传递给它的参数。</p>
</body>
0023:返回值的函数
如何从函数返回值。
<html>
<head>
<script type="text/javas
function myFunction()
{
return ("您好,祝您愉快!")
}
</script>
</head>
<body>
<script type="text/javas
document.write(myFunction())
</script>
<p>body 部分中的脚本调用一个函数。</p>
<p>该函数返回一段文本。</p>
</body>
</html>
0024:返回值的函数
如何从函数返回值。
<html>
<head>
<script type="text/javas
function myFunction()
{
return ("您好,祝您愉快!")
}
</script>
</head>
<body>
<script type="text/javas
document.write(myFunction())
</script>
<p>body 部分中的脚本调用一个函数。</p>
<p>该函数返回一段文本。</p>
</body>
</html>
0025:带有参数并返回值的函数
如何向函数输入两个参数值,并返回值。
<html>
<head>
<script type="text/javas
function product(a,b)
{
return a*b
}
</script>
</head>
<body>
<script type="text/javas
document.write(product(6,5))
</script>
<p>body 部分中的脚本调用一个带有两个参数(6 和 5)的函数。</p>
<p>该函数会返回这两个参数的乘积。</p>
</body>
</html>
评论