Math問題:怎么設(shè)置成,我點一次,就更新一次數(shù),我現(xiàn)在弄得是只能點一次
<!DOCTYPE?html> <html> <head> <meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8"?/> <title>Mathint?</title> <script?type="text/javascript"> var?i=Math.random()*10; function?abc(){ ????document.write(Math.round(i)); ????} </script> </head> <body> <input?type="button"?value="刷新"?onclick="abc()"> </body> </html>
2016-03-10
需要用到location對象里的reload()方法。語法是:location.reload()
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>編程練習(xí)</title>
<script>
var mynum=Math.random();
Math.round(mynum*10);
document.write(Math.round(mynum*10));
function contxt()
{
location.reload();
}
</script>
</head>
<body>
<button type="button" onclick="contxt()">點擊這里</button>
</body>
</html>
2016-03-10
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Mathint </title>
<script type="text/javascript">
function abc(){
var i=Math.random()*10;
? ? document.getElementById("abc").innerText=Math.round(i);
? ? }
</script>
</head>
<body>
<input type="button" value="刷新" onclick="abc()">
<div id="abc"><div>
</body>
</html>