Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <table id="p2146-2-table">
  <thead>
    <tr>
      <th>リスト選択</th>
      <th>リスト名</th>
      <th>リスト順</th>
      <th>追加/削除</th>
    </tr>
  </thead>

  <tbody id="p2146-2-tbody">
    <tr>
      <td>
        <select class="changeList">
          <option>A</option><option>B</option><option>C</option>
        </select>
      </td>
      <td>A</td>
      <td>
        <button class="upList">⬆️上へ</button> 
        <button class="downList">⬇️下へ</button>
      </td>
      <td>
        <input value="+" type="button" class="addList" /> 
        <input value="-" type="button" class="removeList" />
      </td>
    </tr>
  </tbody>
</table>

              
            
!

CSS

              
                #p2146-2-table {
  width: 100%;
  font-size: 14px;
  border-collapse: collapse;
}

#p2146-2-table th,
#p2146-2-table td {
  border: 1px solid #ccc;
  padding: 12px 8px;
  text-align: center;
}

#p2146-2-table th {
  background-color: #ad1457;
  color: #fff;
}

#p2146-2-table input,
#p2146-2-table select {
  width: 100px;
  cursor: pointer;
}

#p2146-2-table i {
  font-size: 18px;
  color: #7cb342;
}

#p2146-2-table input[type='button'] {
  background-color: #f0f0f0;
  border: 1px solid #aaa;
  border-radius: 2px;
  box-shadow: 0 1px 2px #999;
  font-size: 14px;
}

#p2146-2-tbody tr:first-child {
  display: none;
}

              
            
!

JS

              
                $(document).ready(function() {
  // CSSで非表示にした1行目の行を複製し、その行の下に挿入
  $('#p2146-2-tbody>tr')
    .clone(true)
    .insertAfter($('#p2146-2-tbody>tr'));

  // 行を追加する
  $(document).on('change', '.changeList', function() {
    $(this)
      .parent()
      .next()
      .html($(this).val());
  });

  // 行を削除する
  $(document).on('click', '#p2146-2-tbody>tr:gt(1) .upList', function() {
    var t = $(this)
      .parent()
      .parent();
    if (t.prev('tr')) {
      t.insertBefore(t.prev('tr')[0]);
    }
  });

  // 行を一つ上に移動させる
  $(document).on('click', '.downList', function() {
    var t = $(this)
      .parent()
      .parent();
    if (t.next('tr')) {
      t.insertAfter(t.next('tr')[0]);
    }
  });

  // 行を一つ下に移動させる
  $(document).on('click', '.addList', function() {
    $('#p2146-2-tbody>tr')
      .eq(0)
      .clone(true)
      .insertAfter(
        $(this)
          .parent()
          .parent(),
      );
  });

  // 行の一部を変更する
  $(document).on('click', '.removeList', function() {
    $(this)
      .parent()
      .parent()
      .remove();
  });
});

              
            
!
999px

Console