请补全预置代码片段中<script>
标签中间的代码,具体要求如下:
定义一个函数
myFunction
,使预览页面点击按钮循环打印如下内容:
数字是:0 数字是:1 数字是:2 数字是:3 数字是:4
注:该题仅限使用while 循环语句
<!DOCTYPE html>
<html>
<body>
<script>
</script>
<button onclick="myFunction()">打印</button>
<p id="demo"></p>
</body>
</html>
请补全预置代码片段中<script>
标签中间的代码,具体要求如下:
定义一个函数myFunction
,使预览页面点击按钮循环打印如下内容:
数字是:0 数字是:1 数字是:2 数字是:3 数字是:4
注:该题仅限使用while 循环语句
<!DOCTYPE html>
<html>
<body>
<script>
</script>
<button onclick="myFunction()">打印</button>
<p id="demo"></p>
</body>
</html>
<button onclick="myFunction()" type="button">打印</button> <p id="demo"></p> <script> function myFunction() { var i = 0, oIdDemo = document.getElementById('demo'); while (i < 5) { oIdDemo.innerHTML += '数字是: ' + i + '<br />'; i++; } } </script>
举报