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

              
                
<div class="container">
  <h2>Using the event.detail Property</h2>

  <p>The <code>event.detail</code> property provides the current "click" count. Match the button's text to the event it describes and the "click" count will be displayed in the associated input. Only consecutive clicks will be tracked, otherwise the count starts again.</p>

  <p class="btns"><button>click</button> <button>dblclick</button> <button>mouseup</button> <button>mousedown</button> <button>blur</button> <button>focus</button></p>

  <p><input id="click" placeholder="click event"> <input id="dblclick" placeholder="dblclick event"> <input id="mouseup" placeholder="mouseup event"> <input id="mousedown" placeholder="mousedown event"> <input id="blur" placeholder="blur event"> <input id="focus" placeholder="focus event"></p>

  <p>One use case for <code>event.detail</code> is the ability to mimic a triple-click event (or quadruple click, quintuple click, etc.):</p>

  <p><button class="trpl">triple click</button></p>

  <p><input id="trpl" placeholder="triple click event"></p>
</div>
              
            
!

CSS

              
                body {
  font-size: 20px;
  padding: 20px;
  text-align: center;
}

h2 {
  margin-top: 0;  
}

.container {
  max-width: 800px;
  margin: 0 auto;
}

button {
  display: inline-block;
  margin: 2px;
}

output {
  display: block;
  margin-top: 30px;
}

::placeholder {
  color: #ccc;
}

code {
  color: firebrick;
}
              
            
!

JS

              
                let btns = document.querySelector('.btns').querySelectorAll('button'),
    btnT = document.querySelector('.trpl');

for(i of btns) {
  (function(index) {
    index.addEventListener(index.innerHTML, function(e) {
      document.getElementById(index.innerHTML).value = e.detail + ' event(s) occured.';
    });
  })(i);
}

btnT.addEventListener('click', function (e) {
  if (e.detail === 3) {
    trpl.value = 'Triple Click Successful!';
  }
}, false);
              
            
!
999px

Console