JavaScript学习笔记14-if语句

来源:互联网 发布:nat123映射阿里云域名 编辑:程序博客网 时间:2024/06/05 07:48

      本文开始学习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

0 0
原创粉丝点击