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

              
                <form action="" method="post">
        <div class="check" name="area">
            <label><input type="checkbox" value="エリアA"> エリアA</label>
            <label><input type="checkbox" value="エリアB"> エリアB</label>
            <label><input type="checkbox" value="エリアC"> エリアC</label>
            <label><input type="checkbox" value="エリアD"> エリアD</label>
            <label><input type="checkbox" value="エリアE"> エリアE</label>
        </div>
        <div class="check" name="count">
            <label><input type="checkbox" value="01"> 01</label>
            <label><input type="checkbox" value="02"> 02</label>
            <label><input type="checkbox" value="03"> 03</label>
            <label><input type="checkbox" value="04"> 04</label>
            <label><input type="checkbox" value="05"> 05</label>
        </div>
        <div class="check" name="other">
            <label><input type="checkbox" value="その他1"> その他1</label>
            <label><input type="checkbox" value="その他2"> その他2</label>
            <label><input type="checkbox" value="その他3"> その他3</label>
            <label><input type="checkbox" value="その他4"> その他4</label>
            <label><input type="checkbox" value="その他5"> その他5</label>
        </div>
        <div class="check">
            <input type="reset" value="リセットする">
        </div>
    </form>
    <ul>
        <li class="area_field">地域:</li>
        <li class="count_field">数量:</li>
        <li class="other_field">その他:</li>
    </ul>
              
            
!

CSS

              
                form{
    border: 3px #000 solid;
    padding: 30px;
    width:600px;
    background-color: #ffc;
}

.check{
    margin-bottom: 30px;
}
              
            
!

JS

              
                $(function(){
    //チェック値 取得用変数
    var checkVal;
    //name属性用変数
    var name;

    //チェックボックスが変化した際の処理
    $(".check input").on("change",function(){
        //チェックしたボックスの親要素のname属性取得
        name = $(this).parents("div").attr("name");

        //チェックボックスの値を取得
        checkVal = $(this).val();
        //チェックが入った場合
        if($(this).is(":checked")){
            /*
            取得した親要素のname属性を頭に付与したclassをセレクタに指定
                取得した値を地域のテキストに表示
                (appendで追加 / 複数ある場合を考慮してスペースで区切り)
            */
            $("." + name + "_field").append("<span>" + checkVal + " </span>");
        }else{//チェックが外れた場合
            //チェックボックスの値を含むspan要素を削除
            $("span:contains(" + checkVal + ")").remove();
        }
    })
    //リセットボタンをクリックした際の処理
    $("[type='reset']").on("click",function(){
        //span要素を削除
        $("span").remove();
    })
})
              
            
!
999px

Console