<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=BIG5">
<title>第一支javaScript</title>
</head>
<body>
<h2>document.write用法</h2>
<Script type ="text/javascript">
var rx, rx1, rx2, maxNum, minNum;
minNum=0;
maxNum=9;
rx=Math.floor( Math.random() * (maxNum - minNum + 1) ) + minNum;
rx1=Math.floor( Math.random() * (maxNum - minNum + 1) ) + minNum;
rx2=Math.floor( Math.random() * (maxNum - minNum + 1) ) + minNum;
while(rx1==rx || rx1==rx2){
rx1=Math.floor( Math.random() * (maxNum - minNum + 1) ) + minNum;
}
while(rx2==rx || rx2==rx1){
rx2=Math.floor( Math.random() * (maxNum - minNum + 1) ) + minNum;
}
document.write("亂數"+rx+rx1+rx2);
</Script>
</body>
</html>
2016年6月2日 星期四
加法運算器
<!DOCTYPE html >
<html >
<head>
<title>加法運算器</title>
<head>
<title>加法運算器</title>
<script>
function add() {
var a = parseInt(document.getElementById('a').value);
var b = parseInt(document.getElementById('b').value);
document.getElementById('result').value = a+b ;
}
</script>
</head>
<body>
<input id="a" type="text" />+<input id="b" type="text" />
<button onclick="add()">=</button>
<output id="result"></output>
</body>
</html>
<html >
<head>
<title>加法運算器</title>
<head>
<title>加法運算器</title>
<script>
function add() {
var a = parseInt(document.getElementById('a').value);
var b = parseInt(document.getElementById('b').value);
document.getElementById('result').value = a+b ;
}
</script>
</head>
<body>
<input id="a" type="text" />+<input id="b" type="text" />
<button onclick="add()">=</button>
<output id="result"></output>
</body>
</html>
訂閱:
文章 (Atom)