Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

javascriptでtableをループ その1

More than 5 years have passed since last update.

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>
izcomaco
主にBtoBサービスの情報+UI設計・デザイン・コーディングをしています。 html,css→JQuery→chart.jsやらvue.jsやらどうにか使用 →フロントエンドを修行中。 メモ書きや練習がてらで作ったのをのせてます。 自分の反復練習用URLとかものせてます。
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away