250x250
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- 풀스택
- iPhone
- iOS 개발자
- hover
- IOS
- html5
- image
- php
- 애니메이션
- HTML
- 자바스크립트
- front-end
- keyframes
- Animation
- 비전공자
- button
- jQuery
- 백엔드
- CSS
- css3
- 개발자
- react
- ipad
- SWIFT
- 비전공 개발자
- MAC
- javascript
- effect
- xcode
- 프론트엔드
Archives
- Today
- Total
비전공자 개발일기
JQuery4 본문
728x90
SMALL
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<title>OnChange vs OnClick</title>
<style>
.flag {
width: 60px;
height: 60px;
background: #aaa;
border: 3px solid #888;
margin: 1em;
padding: 1em;
text-align: center;
color: white;
font-size: 1.2em;
display: inline-block;
}
.flag.on {
border-color: #c64;
background-color: #e86;
}
</style>
</head>
<body>
<form>
<p>
<label for="tester">
<input type="checkbox" name="tester" id="tester" value="something">
Click Me!
</label>
</p>
</form>
<p><a href="#" id="testlink">Click me to change the 'checked' property with jQuery</a></p>
<p><a href="#" id="testlink2">Click me to manually trigger 'change'</a></p>
<p><a href="#" id="testlink3">Click me to manually trigger 'click'</a></p>
<div class="flag" id="changeFlag">change</div>
<div class="flag" id="clickFlag">click</div>
<script>
$(':checkbox[name="tester"]').on({
click: function (e) {
$('#clickFlag').toggleClass('on');
},
change: function (e) {
$('#changeFlag').toggleClass('on');
}
});
$('#testlink').click(function () {
if (!!$('#tester').prop('checked')) {
$('#tester').prop('checked', false);
} else {
$('#tester').prop('checked', true);
}
});
$('#testlink2').click(function () {
$('#tester').change();
});
$('#testlink3').click(function () {
$('#tester').trigger('click');
});
</script>
</body>
</html>
728x90
LIST