<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>while</title>
<script type="text/javascript">
var mynum =1;//mynum初值化数值为1
while (mynum<=5)
{
document.write("数字:"+mynum);
mynum=mynum+1;
}
</script>
</head>
<body>
</body>
</html>
怎么样使其结果分行显示?
可用</br>标签进行换行
将document.write("数字:"+mynum)改为document.write("数字:"+mynum + "</br>");
document.write("数字:"+mynum+"<br/>");
用</br>标签进行换行
将document.write("数字:"+mynum)改为document.write("数字:"+mynum + "</br>");
因为楼主是在HTML5模式下编程:
可直接使用<br>标签进行换行,
将document.write("数字:"+mynum)改为document.write("数字:"+mynum + "<br>");