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 = contents>
  <input type="checkbox" id="apple" name="apple"
          class="content_list" onchange="displaySelectedFruit()">
  <label for="apple">りんご</label>
  <input type="checkbox" id="orange" name="orange"
          class="content_list" onchange="displaySelectedFruit()">
  <label for="orange">みかん</label>
  <input type="checkbox" id="grape" name="grape"
          class="content_list" onchange="displaySelectedFruit()">
  <label for="grape">ぶどう</label>
  <div>好きなくだもの</div>
  <div id = extracted_words>
    
  </div>

</div>
              
            
!

CSS

              
                
              
            
!

JS

              
                //各チェックボックスをHTMLCollectionで取得
let fruits_check_boxes = document.getElementsByClassName("content_list")

//各チェックボックスが選択されたら呼び出される関数
function displaySelectedFruit(){
  //選択された果物の文字列を入れるための配列
  let displayed_fruits = []
  //表示箇所を取得
  let favorites_fruits = document.getElementById("extracted_words")
  //チェックボックスごとに、選択されているかどうかで文字列用の配列に出し入れを行う
  for(let i = 0; i < fruits_check_boxes.length; i++){
    if(fruits_check_boxes[i].checked){
      displayed_fruits.push(fruits_check_boxes[i].nextElementSibling.textContent) 
    } else {
      let removing_fruit = fruits_check_boxes[i].nextElementSibling.textContent
      displayed_fruits = displayed_fruits.filter(item => (item.match(/${removing_fruit}/)) == null);
    }
  } 
  //表示箇所に選択されている果物を表示
  favorites_fruits.textContent = displayed_fruits
}
              
            
!
999px

Console