제이쿼리 소스
$(document).ready(function(){
//
$(".ico_chk").click(function(){
// 특정 클래스 클릭시
if ( $(this).hasClass("on") ){
//on 클래스가 있는지 확인해서 있다면 지우고
$(this).removeClass("on");
}else {
//on 클래스가 없다면 추가한다.
$(this).addClass("on");
}
});
});
html 소스
<div class="check_agr">
<input id="termAgr" name="termAgr" type="checkbox" class="input_check">
<label for="termAgr" class="ico_chk"> 서비스 약관에 동의합니다.</label>
</div>
css 소스
.ico_check {
display: block;
width: 20px;
height: 20px;
background: url(/images/ico_1.png) no-repeat 0 0;
overflow: hidden;
font-size: 1px;
line-height: 0;
background-position: 0px 0px;
}
.ico_chk.on{
background-position: 0px -15px;
}
이미지 소스
ico_1.png
이렇게 하면
약관 체크시
약관체그 해제시
요런 효과를 볼수 있다.
'jscript' 카테고리의 다른 글
| [jQuery]스크롤 시 특정 위치에서 div 고정시키기 (0) | 2022.07.22 |
|---|---|
| PHP로 간단하게 PC, 모바일 기기 체크하기 (0) | 2018.05.15 |
| PHP로 간단하게 모바일 기기 체크하기 (0) | 2018.02.09 |
| 속성, 내용, 스타일, 데이터 조회 및 변경 (0) | 2018.02.08 |
| If This is Clicked Show This Else Hide This (0) | 2018.02.01 |