2022-06-23 |

For 循环

For 循环

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>滴答编程(dida100.com)</title> 
</head>
<body>

<p>单击按钮将代码块循环执行5次。</p>
<button onclick="myFunction()">点我</button>
<p id="demo"></p>
<script>
function myFunction(){
	var x="",i;
	for (i=0;i<5;i++){
		x=x + "这个数字是" + i + "<br>";
	}
	document.getElementById("demo").innerHTML=x;
}
</script>

</body>
</html>

0

发表评论

    评价:
    验证码: 点击我更换图片
    最新评论