Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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="table-container">
  <thead>
    <tr>
      <th>入力項目</th>
      <th>x2</th>
      <th>x3</th>
      <th>済</th>
    </tr>
  </thead>
  <tbody>
    <tr class="id1">
      <td><input id="change-content" type="text"></td>
      <td><input type="text"></td>
      <td><input type="text"></td>
      <td><input type="checkbox"></td>
    </tr>
    <tr class="id2">
      <td><input id="change-content" type="text"></td>
      <td><input type="text"></td>
      <td><input type="text"></td>
      <td><input type="checkbox"></td>
    </tr>
    <tr class="id3">
      <td><input id="change-content" type="text"></td>
      <td><input type="text"></td>
      <td><input type="text"></td>
      <td><input type="checkbox"></td>
    </tr>
  </tbody>
</table>
              
            
!

CSS

              
                #table-container {
  border: 1px solid;
}
#table-container td {
  text-align:center;
}
#table-container input {
  text-align:right;
}
              
            
!

JS

              
                $("#table-container input[type=text]#change-content").change(function() {
  
  var className = $(this).closest("tr").attr("class");
  var num = $(this).val();
  try {
    tmpNum = parseFloat(num);
    
    // Nanかチェック
    if (isCheckNaN(tmpNum)) {
      $("tr."+className+"  input[type=checkbox]").prop("checked", false);
      $(this).val("");
      return;
    } else {
      num = tmpNum;
      $(this).val(num);
    }
  }
  catch (e) {
    return;
  }
  
  // 項目を変更した行のテキストボックスの値を変更する
  // 最初の行は変更対象外)(not利用)
  $("tr."+className+" input[type=text]").not(':first').each(function(i){
    switch (i) {
      case 0:
        $(this).val(num*2);
        break;
      case 1:
        $(this).val(num*3)
        break;
      default:
        break;
    }
  });
  
  // チェックボックスにチェックを付ける
  $("tr."+className+"  input[type=checkbox]").prop("checked", true);
});

// Nan === Nan -> false
// ↑の性質を利用する
function isCheckNaN(num) {
  return num !== num || typeof num !== "number";
}

              
            
!
999px

Console