LoginSignup
1
1

More than 5 years have passed since last update.

javascriptでtableをループ その1

Last updated at Posted at 2014-11-11

htmlのループしたい箇所に直接書く基本のパターン。

filename
<!DOCTYPE html>
<html lang="ja">
<head>
  <meta charset="UTF-8">
<title>テーブルの行をループで処理</title>
</head>

<body>
  <table>
    <thead>
      <tr>
        <td>数字i</td>
        <td>数字i+2</td>
      </tr>
    </thead>
    <tbody id="tbodyID">
      <script type="text/javascript">
        for (var i = 1; i <= 20; i++) {
          document.write("<tr><td>", i, "</td>");
          document.write("<td>", i + 2,  "</td></tr>");
        }
      </script>
    </tbody>
  </table>
</body>
</html>
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1