问答详情
源自:4-6 反反复复(while循环)

怎样使结果分行显示?

<!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>

怎么样使其结果分行显示?

提问者:水深的一匹 2016-08-24 17:35

个回答

  • Polaris丶
    2016-08-24 17:41:24
    已采纳

    可用</br>标签进行换行

    将document.write("数字:"+mynum)改为document.write("数字:"+mynum + "</br>");

  • lxhcool
    2016-11-28 17:51:02

    document.write("数字:"+mynum+"<br/>");

  • 慕粉3858459
    2016-08-24 17:54:39

    用</br>标签进行换行

    将document.write("数字:"+mynum)改为document.write("数字:"+mynum + "</br>");


  • TuShaoLong
    2016-08-24 17:51:19

    因为楼主是在HTML5模式下编程:

    可直接使用<br>标签进行换行,

    将document.write("数字:"+mynum)改为document.write("数字:"+mynum + "<br>");