Pen Settings



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


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


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.


                <div class='demo'>
  <h2>Names suggestion</h2>
  <p>Please suggest one or more names.</p>
  <div id='name-inputs'>
    <input type='text'>  
  <button id='more-input-button'>+</button>
  <input type='submit' id='submit-button' value='Submit'>
<p><small>This is a demo by Makzan. Created for the <a href=''>Beginning jQuery</a> course.</small></p>


                body {
  padding: 30px 50px;
  font-size: 16pt;
.demo {
  max-width: 600px;
input {
  display: block;
  width: 100%;
  padding: 10px;
  margin: 3px 0;
  background-repeat: no-repeat;
  background-position: 98% 50%;
  opacity: 0.5;
.ok {
  background-image: url(;
.alert {
  background-image: url(;



                // when user clicks the '+' button.
$('#more-input-button').on('click', function(){
  // create a new input dynamically.
  $('#name-inputs').append("<input type='text'>");
  // focus the newly added input.
  $('#name-inputs input:last-child').focus();

// a function that checks all the inputs when called. It applies an alert state or ok state to the input.
function validateInputs() {
  $('#name-inputs > input').each(function(){
    if ($(this).val() === "") {
    } else {

// apply keyboard events to name inputs, for existing and future matching elements.
$('#name-inputs').delegate('input[type="text"]', 'keyup blur', function(){

// logic when user clicks on the submit button.
$('#submit-button').on('click', function(){
  // validate the inputs once more.
  // disable the inputs and button
  $("input").prop("readonly", true);
  $("input[type='submit'], button").prop("disabled", true);
  // fetched the result.
  // an array that store all the values.
  var values = [];
  // loop and get each value.
  $('#name-inputs > input').each(function(){
		// add the value to the result array.    
		values.push( $(this).val() );
  // alert to confirm the result.
  var result = confirm('Please confirm: ' + values.join(', '));
  // when the user confirm the submission.
  if (result) {
    // reset the inputs for 
    $('#name-inputs').html("<input type='text'>");
    $("input[type='submit'], button").prop('disabled', false);
    $('#name-inputs input').focus();
  } else {
    // re-enable the inputs and button for changes
    $('input').prop('readonly', false);
    $("input[type='submit'], button").prop('disabled', false);