關(guān)于document的輸出問(wèn)題
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Math </title>
<script type="text/javascript">
var num = document.write(Math.random()*10+"<br>");
document.write(Math.round(Math.random()*10)+"<br>");
document.write(Math.round(num));
</script>
</head>
<body>
</body>
</html>
最后一個(gè)輸出為什么是NaN啊
2016-11-06
document.write()沒(méi)有返回值。你的?var num = document.write(Math.random()*10+"<br>"); 沒(méi)有意義!
2017-04-10
num的值是Math.random()*10, 然后再用round去四舍五入Math.random()*10,不是輸出內(nèi)容
2016-11-19
不用這句:document.write(Math.round(Math.random()*10)+"<br>");