■関数を作成したい

●引数も戻り値もない関数「function msg()」を呼び出す


●引数も戻り値もある関数を呼び出す


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Script-Type" content="text/javascript">
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>関数を作成したい</title>
<script type="text/JavaScript">
<!--
function msg() {
alert("ボタンが押されました。");
}
function add_data(i,j) {
return i+j;
}
// -->
</script>
<body>
<p>■関数を作成したい</p>
<p>●引数も戻り値もない関数「function msg()」を呼び出す</p>
<form name="fm1">
<p><input type="button" value="ボタンを押して" onclick="msg()"></p>
</form>

<br>
<p>●引数も戻り値もある関数を呼び出す</p>
<script type="text/JavaScript">
<!--
document.write("<p>「function add_data(10,15)」の実行 = "+add_data(10,15)+"</p>");
// -->
</script>
</body>
</html>



★解説★