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">
	<fieldset id="billing">
		<legend>주문자 정보</legend>
		<ol>
			<li>이름 <input type="text" class="copy" name="b_name" value="김재희" id=""></li>
			<li>연락처 <input type="text" class="copy" name="b_telephone" value="010-777-7777"></li>
			<li>우편번호 <input type="text" class="copy" name="b_zip" value="121-747"></li>
			<li>주소 <input type="text" class="copy" name="b_addr1" value="서울시 송파구 잠실본동"></li>
			<li>상세주소 <input type="text" class="copy" name="b_addr2" value="211-2 롯데월드 타워"></li>
		</ol>
	</fieldset>

	<fieldset id="shipping">
		<legend>배송지 정보</legend>
		<p>
			<label for="copy-field">주문자와 동일</label>
			<input type="checkbox" id="copy-field">
		</p>
		<ol>
			<li>이름 <input type="text" class="copy" name="s_name"></li>
			<li>연락처 <input type="text" class="copy" name="s_telephone"></li>
			<li>우편번호 <input type="text" class="copy" name="s_zip"></li>
			<li>주소 <input type="text" class="copy" name="s_addr1"></li>
			<li>상세주소 <input type="text" class="copy" name="s_addr2"></li>
		</ol>
	</fieldset>
</form>
              
            
!

CSS

              
                fieldset {
	float: left;
	width: 45%;
	margin:3em 1%;
	border: 1px solid #ddd;
}
fieldset p {
	margin:-3em 0 2.8em;
	text-align: right;
}
p { clear: both;}
li {
	margin:0.8em 0;
}
              
            
!

JS

              
                var $copyFields = $('#copy-field');

var $billingField = $('#billing .copy');
var $shippingField = $('#shipping .copy');

$copyFields.change(function () {
	var $this = $(this);
	var checked = $this.prop('checked');

	if (checked) {
		$shippingField.each(function (idx) {
			var $this = $(this);
			var value = $billingField[idx].value;
			$this.val(value)
		});
	} else {
		$shippingField.val('');
	}

});

$shippingField.change(function () {
	var count = $shippingField.length;
	// console.log(count);

	var same = true;

	// 주문자 정보 필드의 값을 저장할 변수 billingValue, 배송지 정보 필드의 값을 저장할 변수 shippingValue, for 문을 제아할 변수 i 를 선언
	var billingValue, shippingValue, i;

	for (i = 0; i < count; i++) {
		billingValue = $billingField[i].value;
		shippingValue = $shippingField[i].value;
		// console.log(billingValue, shippingValue);

		// 두 값이 비교해서 다르면 same 변수에 false 를 저장
		if (billingValue != shippingValue) {
			same = false;
			break;
		}

	}

	$copyFields.prop('checked', same);

});
              
            
!
999px

Console