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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <select>
  <option value="url-change">[ jQuery ]URLの一部を変更</option>
  <option value="detach">[ jQuery / .detach() ]イベント・ハンドラを残して要素を削除</option>
  <option value="empty">[ jQuery / empty ]子要素・内容を削除</option>
  <option value="remove">[ jQuery / remove ] 要素を削除</option>
</select>

<div>
  <a href="http://eitch.net/webdesign/jquery/url-change/" target="_blank"><img src="http://eitch.net/wp-content/uploads/2015/11/url-change.jpg"></a>
  <span>タイトル</span>
</div>
              
            
!

CSS

              
                select {
  width: 390px;
  height: 30px;
  margin: 10px; 
}

div {display: none;}

div a {
  width: 400px;
  margin: 20px 0 0;
  display: block;
}

div img {width: 400px;}

div span {
  width: 400px;
  text-align: center;
  display: block;
}
              
            
!

JS

              
                jQuery(function($){
    $('select').change(function(){
      
      // 画像URL取得
      var opval = $(this).val(); 
      var imgSplit = $('div img').attr('src').split('/');
      var imgName = imgSplit[7].split('.');
      var imgUrl = $('div img').attr('src').replace(imgName[0] , opval);
      $('div img').attr('src', imgUrl); 
      
      // リンク取得
      var aSplit = $('div a').attr('href').split('/');
      var aUrl = $('div a').attr('href').replace(aSplit[5] , opval);
      $('div a').attr('href', aUrl);
      
      // タイトル取得
      var str = "";
      $("select option:selected").each(function () {
          str += $(this).text() + " ";
      });
      $("div span").text(str);
      
      // 表示する
      $('div').css('display' , 'block');
    });
});
              
            
!
999px

Console