Pen Settings



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


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


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.


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.


  <ul id="parent-ul-1">
    <li id="li-1" class="my-class">Item 1</li>
    <li id="li-2" class="my-class">Item 2</li>
    <li id="li-3" class="my-class">Item 3</li>
  <p id="display-msg-1"><p>

  <ul id="parent-ul-2">
    <li id="li-4" class="my-class">Item 4</li>
    <li id="li-5" class="my-class">Item 5</li>
    <li id="li-6" class="my-class">Item 6</li>
  <p id="display-msg-2"><p>

  <ul id="parent-ul-3">
    <li id="li-7" class="my-class">Item 7</li>
    <li id="li-8" class="my-class">Item 8</li>
    <li id="li-9" class="my-class">Item 9</li>
  <p id="display-msg-3"><p>

  <button id="unbind" type="button">Unbind Column 3</button>
  <button id="bind" type="button">Bind Column 3</button>
  <p id="display-msg-4"><p>


                $pri: #888;
$pri-light: lighten($pri, 20%);
$pri-dark: darken($pri, 20%);
$pri-dark-x: darken($pri, 30%);
* { box-sizing: border-box; }
body {
  font-family: arial;
  margin: 2em 1em;
  background: #222;
@keyframes play {
   0% { left: 0; }
   50% { left: 20px; }
   100% { left: 0;}
.moveMe {
  animation: play .8s;
  position: relative;
  margin: 0;
section {
  width: 25%;
  float: left;
  padding-right: 1%;
ul {
  width: 100%;
  color: $pri-light;
  li {
    background-color: $pri-dark-x;
    border-bottom: 2px solid $pri-light;
    padding: 1em;
    list-style-type: none;
    cursor: pointer;
p {
  padding: 1em 0 0 0;
  color: #fff;
  font-size: 1em;
button {
  width: 100%;
  display: block;
  border: 0;
  background-color: $pri-dark;
  padding: .5em 1em;
  margin-bottom: 1em;
  font-size: 1em;
  color: $pri-light;
  border: 5px solid  $pri-light;
  &:hover { background-color: $pri-dark-x; }
  &:active { 
    box-shadow: inset 0 0 5px $pri-dark-x;
    background-color: $pri-dark-x; }
  &:focus { outline: 0; }


// Event delegation is useful in that you only place the event listener on the parent to capture the bubbled event - imagine a table of 1000 rows. The callback function lets you handle it in any way.

var dm1 = document.getElementById("display-msg-1");
document.getElementById("parent-ul-1").addEventListener("click", function(e) {
  if( {
    var msg = "Clicked on: " +;
    // You could capture any attribute of this clicked element
    // "ID:" + or "Class:" +
    addRemoveClass(dm1, msg);
function addRemoveClass(c, msg) {
  c.innerHTML = msg;
  c.offsetWidth = c.offsetWidth;
// And with jQuery .delegate
$("#parent-ul-2").delegate( "li", "click", function() {
  var dm2 = $("#display-msg-2");
  var msg = dm2.text( "Clicked on: " + $(this).text());
  jq_addRemoveClass(dm2, msg);
// For .on just reverse the event and target
$("#parent-ul-3").on("click", "li", function() {
  var dm3 = $("#display-msg-3");
  var msg = dm3.text( "Clicked on: " + $(this).text());
  jq_addRemoveClass(dm3, msg);
function jq_addRemoveClass(c, msg) {
// .off - removes both .delegate and .on
$( "#unbind" ).click(function() {
  $( "#parent-ul-3" )
    .off( "click", "li")
    .find( "#display-msg-4" )
    $("#display-msg-4" ).text("Removed .on from C3");
$("#bind").click(function() {
  // Real world, I'd abstract the sect 3 declaration into it's own function
    $("#parent-ul-3").on("click", "li", function() {
      var dm3 = $("#display-msg-3");
      var msg = dm3.text( "Clicked on: " + $(this).text());
      jq_addRemoveClass(dm3, msg);
  $("#display-msg-4").text("Added .on to C3");