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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

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

              
                
  <button id='add'>Add</button>
  <button id='remove'>Remove</button>
  <table>
    <tbody id='theTable'>
      <tr class='.pt-entry'><td>row<td></tr>
      <tr class='.pt-entry-1'><td>row<td></tr>
      <tr class='.pt-entry-2'><td>row<td></tr>
      <tr class='.pt-entry-3'><td>row<td></tr>
    </tbody>
  </table>
              
            
!

CSS

              
                
              
            
!

JS

              
                (function(){
//Define your elements
  var table = document.getElementById('theTable'),  
// your parent element you are adding content to
      rows = table.querySelectorAll('tr'),
//initial rows for counting
      rowCount = rows.length,
//how many rows exist
      addedRow = document.createElement('tr'),
//create the new row
      addButton = document.getElementById('add'),
      removeButton = document.getElementById('remove');
//basic buttons for example

  function addRow(){
    var thisRow = addedRow.cloneNode(true);
//clone your created row
    thisRow.setAttribute('class','.pt-entry-' + rowCount);
//set the class to be class + the row count (will increment) 
    rowCount += 1;
//increment

    thisRow.innerHTML = '<td>row</td>';
//adding whatever, not necessary
    table.appendChild(thisRow);
//puts the row in to your parent

  }

  function removeRow(){

    var items = table.querySelectorAll('tr');
//get the new list of rows
    if (rowCount > 1){
    table.removeChild(items[rowCount - 1]);
    }
//remove the last item
    rowCount -= 1;
//decrement

  }

addButton.addEventListener('click', function(e){

    addRow();

  });

  removeButton.addEventListener('click', function(e){

    removeRow();

  });
  
})();
              
            
!
999px

Console