2015年1月19日月曜日

開発環境

Head First HTML5 Programming: Building Web Apps with Javascript(Eric Freeman (著)、Elisabeth Robson (著)、O'Reilly Media)のChapter 2(Introducing JavaScript and the DOM: A Little Code)、SHARPEN YOUR PENCIL(No. 1637)を解いてみる。

その他参考書籍

SHARPEN YOUR PENCIL(No. 1637)

HTML5 (BBEdit, Emacs)

sample1637.html

<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Temperatures</title>
    <script>
      var showTemps = function (){
          var tempByHours =[59.2, 60.1, 63, 65, 62],
              i,
              max,
              theTemp,
              id,
              li;
      
          for (i = 0, max = tempByHours.length; i < max; i += 1) {
              theTemp = tempByHours[i];
              id = "temp" + i;
              li = document.getElementById(id);
              if (i === 0) {
                  li.innerText = 'The temperature at noon was ' + theTemp;
              } else {
                  li.innerText = 'The temperature at ' + i + ' was ' + theTemp;
              }
          }
      };
      
      window.onload = showTemps;
    </script>
  </head>
  <body>
    <h1>Temperatures</h1>
    <ul>
      <li id="temp0"></li>
      <li id="temp1"></li>
      <li id="temp2"></li>
      <li id="temp3"></li>
      <li id="temp4"></li>
    </ul>
  </body>
</html>
 

0 コメント:

コメントを投稿