Blogger Information
Blog 9
fans 0
comment 0
visits 6539
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
3.25 if else判断语句
师太的小迷弟的博客
Original
861 people have browsed it

总结:

if(条件){

    如果条件成立就输出这里的代码块

}else{

    否则就输出这里的

}

if(条件){

    如果条件成立就输出这里的代码块

}else if(条件){

    否则如果这里的条件成立就输出这里的代码块

}else{

    以上条件都不符合就输出这里的

}

闰年案例


实例

<!DOCTYPE html>
<html>
<head>
	<title></title>
</head>
<body>
	<script type="text/javascript">
		var a,b
		a=2000;
		b=a%4;
		if(b==0){
			// document.write('是闰年')
			alert('是闰年')
		}else{
			// document.write('不是闰年')
			alert('不是闰年')
		}
		
	</script>
</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例

成绩案例

实例

<!DOCTYPE html>
<html>
<head>
	<title></title>
</head>
<body>
	<script type="text/javascript">

		var c
		c=99;
		if(c>=90&&c<=100){
			document.write('优秀')
		}else if(c>=80&&c<=89) {
			document.write('良好')
		}else if(c>=70&&c<=79){
			document.write('良')
		}else if(c>=60&&c<=69){
			document.write('及格')
		}else if(c>=59){
			document.write('不及格')
		}
	</script>
</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例

Correction status:Uncorrected

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post