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

              
                <div class="container" id="app">
  <form>
    <div
      class="row justify-content-center"
      v-for="(attendee, index) in attendees"
      :key="index"
    >
      <div class="col-sm-3">
        <div class="form-group">
          <label class="sr-only">Name</label>
          <input
            class="form-control"
            aria-describedby="emailHelp"
            placeholder="Enter name"
            v-model="attendee.name"
            required
          >
        </div>
      </div>
      <div class="col-sm-3">
        <div class="form-group">
          <label class="sr-only">Email address</label>
          <input
            type="email"
            class="form-control"
            placeholder="Enter email"
            v-model="attendee.email"
            required
          >
        </div>
      </div>
      <div class="col-sm-2 text-left">
        <button
          type="button"
          class="btn btn-light"
          @click.prevent="removeAttendee(index)"
          v-show="quantity > 1"
        >
          <span aria-hidden="true">&times;</span>
          Remove
        </button>
      </div>
    </div>
    <div class="row justify-content-center">
      <div class="col-sm-6"></div>
      <div class="col-sm-2">
        <button
          type="button"
          class="btn btn-secondary"
          v-on:click="addAttendee"
        >
          Add Attendee
        </button>
      </div>
    </div>
    <hr>
    <div class="row justify-content-center">
      <div class="col-sm-6">
        <span class="unit-price">${{ cost }} ea.</span>
      </div>
      <div class="col-sm-2 text-left">
        <button
          type="submit"
          class="btn btn-primary"
        >
          Pay ${{ checkoutTotal }}
        </button>
      </div>
    </div>
  <form>
</div>
              
            
!

CSS

              
                body {
  margin: 3em
}

button {
  cursor: pointer;
}

.unit-price {
  margin-right: 2rem;
  color: #999;
}
              
            
!

JS

              
                
(function () {
  var app = new Vue({
    el: '#app',
    data: {
      attendees: [{ name: '', email: '' }],
      cost: 9.99,
    },
    computed: {
      quantity: function () {
        return this.attendees.length;
      },
      checkoutTotal: function () {
        return this.cost * this.quantity;
      }
    },
    methods: {
      removeAttendee: function (index) {
        this.attendees.splice(index, 1);
      },
      addAttendee: function (event) {
        event.preventDefault();
        this.attendees.push({
          name: '',
          email: '',
        });
        
        this.$nextTick(function () {
          console.log(this.$el.id);
        }.bind(this));
      }
    }
  });
})();

              
            
!
999px

Console