Pen Settings

HTML

CSS

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

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

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.

HTML

              
                <div class="search">
	<span class="search_item is-active" data-group="">ALL</span>
	<span class="search_item" data-group="a">グループA</span>
	<span class="search_item" data-group="b">グループB</span>
	<span class="search_item" data-group="c">グループC</span>
	<span class="search_item" data-group="d">グループD</span>
	<span class="search_item" data-group="e">グループE</span>
	<span class="search_item" data-group="f">グループF</span>
	<span class="search_item" data-group="g">グループG</span>
	<span class="search_item" data-group="h">グループH</span>
</div>

<ul class="list">
	<li class="list_item" data-group="a">ロシア</li>
	<li class="list_item" data-group="c">フランス</li>
	<li class="list_item" data-group="f">スウェーデン</li>
	<li class="list_item" data-group="b">ポルトガル</li>
	<li class="list_item" data-group="e">スイス</li>
	<li class="list_item" data-group="f">ドイツ</li>
	<li class="list_item" data-group="e">セルビア</li>
	<li class="list_item" data-group="h">ポーランド</li>
	<li class="list_item" data-group="c">デンマーク</li>
	<li class="list_item" data-group="g">イングランド</li>
	<li class="list_item" data-group="b">スペイン</li>
	<li class="list_item" data-group="g">ベルギー</li>
	<li class="list_item" data-group="d">アイスランド</li>
	<li class="list_item" data-group="d">クロアチア</li>
	<li class="list_item" data-group="b">イラン</li>
	<li class="list_item" data-group="f">韓国</li>
	<li class="list_item" data-group="h">日本</li>
	<li class="list_item" data-group="a">サウジアラビア</li>
	<li class="list_item" data-group="c">オーストラリア</li>
	<li class="list_item" data-group="g">チュニジア</li>
	<li class="list_item" data-group="d">ナイジェリア</li>
	<li class="list_item" data-group="b">モロッコ</li>
	<li class="list_item" data-group="h">セネガル</li>
	<li class="list_item" data-group="a">エジプト</li>
	<li class="list_item" data-group="f">メキシコ</li>
	<li class="list_item" data-group="e">コスタリカ</li>
	<li class="list_item" data-group="g">パナマ</li>
	<li class="list_item" data-group="e">ブラジル</li>
	<li class="list_item" data-group="a">ウルグアイ</li>
	<li class="list_item" data-group="d">アルゼンチン</li>
	<li class="list_item" data-group="h">コロンビア</li>
	<li class="list_item" data-group="c">ペルー</li>
</ul>
              
            
!

CSS

              
                .search_item {
	display: inline-block;
	padding: 3px;
	cursor: pointer;
}
.search_item.is-active {
	color: white;
	background-color: black;
}
.is-hide {
	display: none;
}
              
            
!

JS

              
                var searchItem = '.search_item';   // 絞り込む項目を選択するエリア
var listItem = '.list_item';       // 絞り込み対象のアイテム
var hideClass = 'is-hide';         // 絞り込み対象外の場合に付与されるclass名
var activeClass = 'is-active';     // 選択中のグループに付与されるclass名

$(function() {
	// 絞り込みを変更した時
	$(searchItem).on('click', function() {
		$(searchItem).removeClass(activeClass);
		var group = $(this).addClass(activeClass).data('group');
		search_filter(group);
	});
});

/**
 * リストの絞り込みを行う
 * @param {String} group data属性の値
 */
function search_filter(group) {
	// 非表示状態を解除
	$(listItem).removeClass(hideClass);
	// 値が空の場合はすべて表示
	if(group === '') {
		return;
	}
	// リスト内の各アイテムをチェック
	for (var i = 0; i < $(listItem).length; i++) {
		// アイテムに設定している項目を取得
		var itemData = $(listItem).eq(i).data('group');
		// 絞り込み対象かどうかを調べる
		if(itemData !== group) {
			$(listItem).eq(i).addClass(hideClass);
		}
	}
}
              
            
!
999px

Console