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

              
                <img class="onoff-btn" src="http://repop.jp/blogger/img/btn-off.png">
<p id="chk-btn">▶テスト用Storageを確認する</p>
<p id="clear-btn">▶テスト用Storageを削除する</p>

              
            
!

CSS

              
                body {
  height: 300px;
  margin: 5px;
}

.onoff-btn {
   width: 100px;
   cursor: pointer;
   cursor: hand;
}

#chk-btn{
  font-size: 18px;
  color:blue;
  cursor: pointer;
  cursor: hand;
}

#clear-btn{
  font-size: 18px;
  color:green;
  cursor: pointer;
  cursor: hand;
}
              
            
!

JS

              
                
var onimg = "http://repop.jp/blogger/img/btn-on.png";
var offimg = "http://repop.jp/blogger/img/btn-off.png";

//localStorageからuserSetの情報を取得してonoffに代入
var onoff = localStorage.getItem("userSet");

//取得した情報がonなら画像差し替え
//offまたはlocalStorageに保存データがなかった場合はoffを代入
   if(onoff == "on") {
         $(".onoff-btn").attr('src',onimg);
   }else{
         onoff = "off";
   }

//クリックされた際にlocalStorageに保存して画像の差し替え
$('.onoff-btn').click(function() {
   switch (onoff) {
      case "off":
         onoff = "on";
         localStorage.setItem("userSet","on");
         $(this).attr('src',onimg);
         break;
       
      case "on":
         onoff = "off";
         $(this).attr('src',offimg);
         localStorage.setItem("userSet","off");
         break;
   }
});

//このコンテンツでのlocalStorageを確認する
$('#chk-btn').click(function() {
  alert("localStorageのuserSetには文字列\"" + localStorage.getItem("userSet") + "\"が保存されています");
});

//このコンテンツでのlocalStorageを破棄する
$('#clear-btn').click(function() {
  localStorage.removeItem("userSet");
  alert("テスト用localStorageを破棄しました");
});
              
            
!
999px

Console