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

              
                <h2>jQuery Filtering Demo</h2>
<p>Just trying to figure out how to best utilize jquery's .filter() function for future projects.</p>
<p>
		<button class="f-all is-active">All Items</button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<button class="f-red">Filter Red Items</button>
		<button class="f-blue">Filter Blue Items</button>
		<button class="f-green">Filter Green Items</button>
</p>

<div class="red">First</div>
<div class="red">Second</div>
<div class="blue">Third</div>
<div class="green">Fourth</div>
<div class="red">Fifth</div>
<div class="blue">Sixth</div>
<div class="blue">Seventh</div>
<div class="green">Eighth</div>

<p><small>Colors from <a href="http://clrs.cc/">http://clrs.cc/</a></small></p>
              
            
!

CSS

              
                @import 'compass/css3';

$red: #ff4136;
$green: #2ecc40;
$blue: #0074d9;

body {
  padding: 10%;
  font-family: sans-serif;
}

button {
  padding: 1em;
  border: 0;
  margin: 0.25em;
  color: #fff;
  cursor: pointer;
	outline: none;
	
	&.is-active {
		@include transform(scale(1.15));
	}
}

.f-red {
  background: $red;
  &:hover { background: darken($red, 15%); }
}
.f-green {
  background: $green;
  &:hover { background: darken($green, 15%); }
}
.f-blue {
  background: $blue;
  &:hover { background: darken($blue, 15%); }
}
.f-all {
  background: #333;
  &:hover { background: darken(#333, 15%); }
}

.red, .green, .blue {
  color: #fff;
  padding: 1em;
  margin-bottom: 0.25em;
}

.red { background: $red; }
.green { background: $green; }
.blue { background: $blue; }
              
            
!

JS

              
                var fActive;

function filterColor(color){
  if(fActive != color){
    $('div').filter('.'+color).slideDown();
    $('div').filter(':not(.'+color+')').slideUp();
    fActive = color;
		$('button').removeClass("is-active");
  }
}

$('.f-red').click(function(){ filterColor('red'); $(this).addClass("is-active"); });
$('.f-blue').click(function(){ filterColor('blue'); $(this).addClass("is-active"); });
$('.f-green').click(function(){ filterColor('green'); $(this).addClass("is-active"); });

$('.f-all').click(function(){
  $('div').slideDown();
  fActive = 'all';
	$(this).addClass("is-active");
});
              
            
!
999px

Console