cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <h2>Sort News</h2>
<select name="sort-news" id="sort-news">
	<option value="All">All news</option>
	<option value="Cat1">Category 1</option>
	<option value="Cat2">Category 2</option>
	<option value="Cat3">Category 3</option>
</select> 
<hr />
<section class="news-list">
  <article class="news-item" data-category="Cat1">
	<div class="thumb">
		<img alt="Our ALT text here" title="Our title here" src="http://placehold.it/150x150">
	</div>
	<div class="news-txt">
		<h3><a href="">A news title</a></h3>
		<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua...</p>
	</div>
</article>
<article class="news-item" data-category="Cat2">
	<div class="thumb">
		<img alt="Our ALT text here" title="Our title here" src="http://placehold.it/150x150">
	</div>
	<div class="news-txt">
		<h3><a href="">A news title</a></h3>
		<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua...</p>
	</div>
</article>
<article class="news-item" data-category="Cat3">
	<div class="thumb">
		<img alt="Our ALT text here" title="Our title here" src="http://placehold.it/150x150">
	</div>
	<div class="news-txt">
		<h3><a href="">A news title</a></h3>
		<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua...</p>
	</div>
    </article>
  </section>
  <script src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-12/jquery-2.0.3.min_1.js"></script>
            
          
!
            
              body {
	font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.news-item { display:inline-block; vertical-align:top; width:300px;}  
            
          
!
            
              //Filter News
$('select#sort-news').change(function() {
	var filter = $(this).val()
	filterList(filter);
});

//News filter function
function filterList(value) {
	var list = $(".news-list .news-item");
	$(list).fadeOut("fast");
	if (value == "All") {
		$(".news-list").find("article").each(function (i) {
			$(this).delay(200).slideDown("fast");
		});
	} else {
		//Notice this *=" <- This means that if the data-category contains multiple options, it will find them
		//Ex: data-category="Cat1, Cat2"
		$(".news-list").find("article[data-category*=" + value + "]").each(function (i) {
			$(this).delay(200).slideDown("fast");
		});
	}
}
            
          
!
999px
Loading ..................

Console