(). :
function (){
;
.......
;
}
function, , ( ), , .. . .
. html- :
<html>
<head>
<title> </title>
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<div onClick="showMessage();"> </div>
</body>
</html>
, div- (.. " ") "showMessage". script.js "showMessage". script.js :
function showMessage(){
alert (" div-");
}
, :
1) html- (onClick, onMouseUp ..), , , .
2) .js , .. , , ( ).
, . html- :
<html>
<head>
<title> </title>
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<form name="forma1">
<input type="text" name="t1" size="10"><br><br>
<input type="text" name="t2" size="10"><br><br>
<input type="button" name="button" value=""><br><br>
<input type="text" name="res" size="10">
</form>
</body>
</html>
:
, "". , . , "", . "areaRectangle":
|
|
.......
<input type="button" name="button" value=""
onClick="areaRectangle();"><br><br>
.......
"areaRectangle". script.js :
function areaRectangle(){
}
. : a - , b - , s - :
function areaRectangle(){
var a;
var b;
var s;
}
(value) a (document), "forma1", "t1". document.forma1.t1.value, .. . (value).
b - document.forma1.t2.value.
s - a b. :
function areaRectangle(){
var a=document.forma1.t1.value;
var b=document.forma1.t2.value;
var s=a*b;
}
"res" . . , , "forma1", "res", (value) s. :
function areaRectangle(){
var a=document.forma1.t1.value;
var b=document.forma1.t2.value;
var s=a*b;
document.forma1.res.value=s;
}