乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      事半功倍之Javascript [2]

       ShangShujie 2007-06-10

      第三章 創(chuàng)建表達式

      1.使用算術(shù)運算符

      <script>
      var1=12
      var2=10
      varadd=var1+var2
      varsub=var1-var2
      varmult=var1*var2
      vardiv=var1/var2
      varmod=var1%var2
      document.write("數(shù)據(jù)1是:"+var1+"<br>")
      document.write("數(shù)據(jù)2是:"+var2+"<br>")
      document.write("數(shù)據(jù)相加是:"+varadd+"<br>")
      document.write("數(shù)據(jù)相減是:"+varsub+"<br>")
      document.write("數(shù)據(jù)相乘是:"+varmult+"<br>")
      document.write("數(shù)據(jù)相除是:"+vardiv+"<br>")
      document.write("數(shù)據(jù)相除取余數(shù)是:"+varmod+"<br>")
      </script>

      2.遞增變量和遞減變量

      <script>
      days=1
      document.write("輸出變量"+days+"<br>")
      days++
      document.write("遞增后變量變?yōu)椋?+days)
      </script>

      3.創(chuàng)建比較表達式

      <script>
      daysofmonth=28
      if(daysofmonth==28)
      month="february"
      document.write("days of month:"+daysofmonth+"<br>")
      document.write("month:"+month)
      </script>

      4.創(chuàng)建邏輯表達式

      <script>
      dayofmonth=28
      if(dayofmonth==28 || dayofmonth==29)
      month="february"
      document.write("days of month:"+dayofmonth+"<br>")
      document.write("month:"+month)
      </script>

      5.使用條件運算符

      <script language="javascript">
      stomach="hungry";
      time="5:00";
      (stomach=="hungry"&&time=="5:00") ? eat = "dinner":eat="a snack";
      document.write("輸出結(jié)果"+eat);
      </script>

      6.識別數(shù)字

      <script>
      var1=24;
      (isNaN(var1))?document.write("變量var1"+var1+"不是數(shù)字"):Document.write("變量var1"+var1+"是數(shù)字")
      </script>

      第四章 控制程序流程

      1.使用IF –Else語句

      <script>
      month="december"
      date=25
      if(month=="december" && date==25)
      document.write("今天是圣誕節(jié),商店關(guān)門")
      else
      document.write("歡迎,您來商店購物")
      </script>

      2.使用for 循環(huán)

      <script>
      for (count=1;count<=10;count++)
      document.write("輸出第"+count+"句"+"<br>")
      </script>

      3.使用while循環(huán)

      <script>
      count=1
      while(count<=15){
      document.write("輸出第"+count+"句" +"<br>")
      count++}
      </script>

      4.中斷循環(huán)

      <script>
      count=1
      while(count<=15){
      count++
      if(count==8)
      break;
      document.write("輸出第"+count+"句"+"<br>")}
      </script>

      5.繼續(xù)循環(huán)

      <script>
      count=1
      while(count<=15){
      count++
      if(count==8)
      continue;
      document.write("輸出第"+count+"句"+"<br>")}
      </script>

      6.使用javascript定時器

      <script>
      function rabbit()
      {document.write("輸出語句")
      }
      </script>
      <body onload=window.setTimeout(rabbit(),5000)>

      7.設(shè)置定期間隔

      <script>
      window.setInterval("document.form1.text2.value=document.form1.text1.value",3000)
      </script>
      <form name=form1>
      <input type=text name=text1><br>
      <input type=text name=text2><br>
      </form>

      8.清除超時和間隔

      <script>
      stop=window.setInterval("document.form1.text2.value=document.form1.text1.value",300)
      </script>
      <form name=form1>
      <input type=text name=text1><br>
      <input type=text name=text2><br>
      <input type=button name=button1 value=" 清除超時和間隔" onclick=clearInterval(stop)>
      </form>

        本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
        轉(zhuǎn)藏 分享 獻花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多