JavaScript基础教程

文章39 |   阅读 17557 |   点赞0

来源:https://blog.csdn.net/u011541946/category_6887610.html

JavaScript学习笔记14-if语句

x33g5p2x  于2022-03-06 转载在 其他  
字(0.5k)|赞(0)|评价(0)|浏览(416)

本文开始学习if语句,和大部分语言一样,JavaScript 中if语句,基本格式如下:

if(条件为真){

代码块;

}

<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
</head>
<body>
<script type ="text/javascript">
		var apples = 35;
		var hotdogs = 76;
		if (apples < hotdogs){
			document.write("yea it worked!");
		}
</script>
</body>
</html>

自己修改下数字大小,还有以下条件,测试运行看看。

apples == hotdogs

apples != hotdogs

apples > hotdogs

apples >= hotdogs

apples <= hotdogs

相关文章