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 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

              
                <div class="col-md-12">
  <h1 class="text-center">
    Differences in event handlers
  </h1>
  <hr />
</div>
<div class="row">
  <div class="col-sm-6">
    <h4 class="text-center">2 handlers</h4>
    <h4 class="text-center">Individually bound to target elements <br /> (anchor tag)</h4>
    <p class="text-center">
      <strong class="text-center">Child icon element is clickable</strong>
    </p>
    <ul class=" text-center list-unstyled master">
      <li>
        <a href="#" class="collapse-nav burrito-btn-1">
          <i class="fa fa-plus-square"></i> Burrito 1
        </a>
        <ul class="sub-nav burrito-1 list-unstyled">
          <li>Mini Burrito 1</li>
          <li>Mini Burrito 2</li>
          <li>Mini Burrito 3</li>
        </ul>
      </li>
      <li>
        <a href="#" class="collapse-nav burrito-btn-2">
          <i class="fa fa-plus-square"></i> Burrito 2
        </a>
        <ul class="sub-nav burrito-2 list-unstyled">
          <li>Mini Burrito 1</li>
          <li>Mini Burrito 2</li>
          <li>Mini Burrito 3</li>
        </ul>
      </li>
    </ul>
  </div>
  <div class="col-sm-6">
    <h4 class="text-center">1 handler</h4>
    <h4 class="text-center">Bound to containing element <br/> (ul tag with a tag as parameter)</h4>
    <p class="text-center">
      <strong>Child icon element is <em>not</em> clickable</strong>
    </p>
    <ul class="text-center list-unstyled master taco">
      <li>
        <a href="#" class="collapse-nav taco-btn">
          <i class="fa fa-plus-square"></i> Taco 1
        </a>
        <ul class="sub-nav taco list-unstyled">
          <li>Mini Taco 1</li>
          <li>Mini Taco 2</li>
          <li>Mini Taco 3</li>
        </ul>
      </li>
      <li>
        <a href="#" class="collapse-nav">
          <i class="fa fa-plus-square"></i> Taco 2
        </a>
        <ul class="sub-nav list-unstyled">
          <li>Mini Taco 1</li>
          <li>Mini Taco 2</li>
          <li>Mini Taco 3</li>
        </ul>
      </li>
    </ul>
  </div>
</div>
<div class="row">
  <div class="col-sm-6">
    <h4 class="text-center">2 handlers</h4>
    <h4 class="text-center">Bound directly to each icon element</h4>
    <p class="text-center"><strong>Only the icon element is clickable</strong></p>
    <ul class="text-center list-unstyled">
      <li>
        <a href="#" class="fajita-btn-1"><i class="fa fa-plus-square"></i> Fajita 1</a>
        <ul class="sub-nav fajita-1 list-unstyled">
          <li>Mini Fajita 1</li>
          <li>Mini Fajita 2</li>
          <li>Mini Fajita 3</li>
        </ul>
      </li>
      <li>
        <a href="#" class="fajita-btn-2"><i class="fa fa-plus-square"></i> Fajita 2</a>
        <ul class="sub-nav fajita-2 list-unstyled">
          <li>Mini Fajita 1</li>
          <li>Mini Fajita 2</li>
          <li>Mini Fajita 3</li>
        </ul>
      </li>
    </ul>
  </div>
  <div class="col-sm-6">
    <h4 class="text-center">1 handler</h4>
    <h4 class="text-center">
      Bound directly to containing element<br />
      (ul tag with i tag as parameter)
    </h4>
    <p class="text-center"><strong>Only the icon element is clickable</strong></p>
    <ul class="text-center chimichanga list-unstyled">
      <li>
        <a href="#"><i class="fa fa-plus-square collapse-chimichanga"></i> Chimichanga 1</a>
        <ul class="sub-nav list-unstyled">
          <li>Mini Chimichanga 1</li>
          <li>Mini Chimichanga 2</li>
          <li>Mini Chimichanga 3</li>
        </ul>
      </li>
      <li>
        <a href="#" ><i class="fa fa-plus-square collapse-chimichanga"></i> Chimichanga 2</a>
        <ul class="sub-nav list-unstyled">
          <li>Mini Chimichanga 1</li>
          <li>Mini Chimichanga 2</li>
          <li>Mini Chimichanga 3</li>
        </ul>
      </li>
    </ul>
  </div>
</div>
              
            
!

CSS

              
                .master {
  margin: 30px;
}

a:hover,
a:focus {
  text-decoration: none;
  opacity: 0.6;
}

.sub-nav {
  display: none;
  padding-left: 45px;
}
              
            
!

JS

              
                $('.burrito-btn-1').on('click', function(){
	$('.burrito-1').slideToggle();
});

$('.burrito-btn-2').on('click', function(){
	$('.burrito-2').slideToggle();
});

$('.taco').on('click', '.collapse-nav', function(event) {
	$(event.target).nextAll('.sub-nav').slideToggle();
});

$('.fajita-btn-1 .fa').on('click', function() {
  $('.fajita-1').slideToggle();
})

$('.fajita-btn-2 .fa').on('click', function() {
  $('.fajita-2').slideToggle();
})

$('.chimichanga').on('click', '.collapse-chimichanga', function(event) {
  $(event.target).parent().nextAll('.sub-nav').slideToggle();
});

$('.quesadilla').on('click', '.mini-collapse', function(event) {
  $(event.target).parent().nextAll('.sub-nav').toggleSlide();
});
              
            
!
999px

Console