30 lines
824 B
HTML
30 lines
824 B
HTML
|
<html>
|
||
|
<head>
|
||
|
<title>Example 7.10</title>
|
||
|
<script>
|
||
|
function getValue()
|
||
|
{
|
||
|
var numMice = 12;
|
||
|
document.getElementById('first').innerHTML = (numMice);
|
||
|
numMice = changeValue(numMice);
|
||
|
document.getElementById('third').innerHTML = (numMice);
|
||
|
}
|
||
|
function changeValue(x)
|
||
|
{
|
||
|
var x = 5;
|
||
|
document.getElementById('second').innerHTML = (x);
|
||
|
return x;
|
||
|
}
|
||
|
|
||
|
|
||
|
</script>
|
||
|
</head>
|
||
|
<body><table align="center" width = "70%"><tr><td><br />
|
||
|
<input type ="button" onclick="getValue()" value = "Can you change the number? Try it"><br />
|
||
|
<h3>The value of numMice is: <span id = "first"> </span></h3>
|
||
|
<h3>The value of x, in the changeValue() function is: <span id = "second"> </span></h3>
|
||
|
<h3>The value of numMice after calling the changeValue() function is: <span id = "third"> </span></h3>
|
||
|
</td></tr></table>
|
||
|
</body>
|
||
|
</html>
|