Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <!-- div.button.button--${button$}*4 -->
<div class="left">
	<div class="button button--1" data-article="article1">button1</div>
	<div class="button button--2" data-article="article2">button2</div>
	<div class="button button--3" data-article="article3">button3</div>
	<div class="button button--4" data-article="article4">button4</div>
<div class="right">
	<div class="article article--active article1" data-article="article1" data-color="#9EFF00">article1</div>
	<div class="article article2" data-article="article2" data-color="#FF1F00">article2</div>
	<div class="article article3" data-article="article3" data-color="#001BFF">article3</div>
	<div class="article article4" data-article="article4" data-color="#FF00E8">article4</div>

	width: 100px
	line-height: 30px
	border: 1px solid black
	border-radius: 10px
	text-align: center

		background-color: #9EFF00
		background-color: #FF1F00
		background-color: #001BFF
		background-color: #FF00E8

	float: left

	float: left
	width: 200px
	height: 150px
	padding: 20px
	background-color: yellow
	text-align: center

	display: none

		display: block
              class Search {
	constructor() {

	init() {

	setConst() {
		this.$window = $(window);
		this.$clickTarget = $(".button");
		this.allArticle = $(".article");
		this.slideTarget = $(".right");
		this.searchData = "article";
		this.activeClass = "article--active"
		//State 現在開いている記事がどれか
		this.oepnedTargetData = "article1";
		this.targetData = null;
		this.$animationTarget = null;
		this.duration = 500;
	attachClickEvent() {
		this.$clickTarget.on("click.test", (event) => {
			const $target = $(event.currentTarget);
			this.targetData = $target.data(this.searchData);
			this.allArticle.each((index, element) => {
				const $element = $(element);

				if (!($element.data(this.searchData) === this.targetData)) {
					//jQueryのメソッド「.each」の中でreturn true をすると、
					return true;

				if (this.targetData === this.oepnedTargetData) {
					//jQueryのメソッド「.each」の中でreturn false をすると、
					//全ての要素への実行を飛ばす。つまり each全体の実行がこの段階で終わる
					return false;

				this.$animationTarget = $element;
				this.color = $element.data("color");

	listenEvent() {
		this.$window.on("trigger.test", () => {
			this.slideTarget.velocity("slideUp", {
				duration: this.duration,
				complete: () => {
					this.slideTarget.css("background-color", this.color)
					.velocity("slideDown", {
						duration: this.duration,
						complete: () => {
							this.oepnedTargetData = this.targetData;

new Search();

🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.