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="" id="frm">

	<p>
		Select your favorite sports
		(<label for="sportAll">select all</label>
		<input type="checkbox" name="dummy" id="sportAll">)
	</p>
	<ul>
		<li>
			<label for="Baseball">Baseball</label>
			<input type="checkbox" name="sports" id="Baseball"></li>
		</li>
		<li>
			<label for="Basketball">Basketball</label>
			<input type="checkbox" name="sports" id="Basketball"></li>
		</li>
		<li>
			<label for="Hockey">Hockey</label>
			<input type="checkbox" name="sports" id="Hockey"></li>
		</li>
		<li>
			<label for="Soccer">Soccer</label>
			<input type="checkbox" name="sports" id="Soccer"></li>
		</li>
	</ul>

</form>
              
            
!

CSS

              
                
              
            
!

JS

              
                var $sportAll = $('#sportAll');
$sportAll.change(function () {
	var $this = $(this);
	var checked = $this.prop('checked'); // checked 문자열 참조(true, false)
	// console.log(checked);
	$('input[name="sports"]').prop('checked', checked);

});

var boxes = $('input[name="sports"]');
boxes.change(function () {
	// 첫 번째 방법
	/*
	var selectAll = true;
	var count = boxes.length;
	var i = 0;
	for (; i < count; i++) {
		if (!boxes[i].checked) {
			selectAll = false;
			break;
		}
	}
	*/

	// 두 번째 방법
	var boxLength = boxes.length;
	// 체크된 체크박스 갯수를 확인하기 위해 :checked 필터를 사용하여 체크박스만 선택한 후 length 프로퍼티를 확인
	var checkedLength = $('input[name="sports"]:checked').length;
	var selectAll = (boxLength == checkedLength);

	$sportAll.prop('checked', selectAll);

});
              
            
!
999px

Console