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 | 29 | 30 | 31 |
Tags
- mysql
- element추가
- strtotime
- mb_strimwidth
- date
- Selector
- HTML
- input
- 문자열포함여부
- ucfirst
- parent of iframe
- date포맷
- accept
- 쿠키
- php
- CSS
- JQuery
- Javascript
- attr
- 세션
- 웹프로그래밍
- strpos
- indexOf
- 시간계산
- disabled
- SubString
- 세션사용법
- File
- 이전주소
- Meta Tag
Archives
- Today
- Total
Heojju
[jQuery] 제이쿼리에서 클래스(class) 이름 추가/삭제 본문
▤ 클래스 추가 [addClass]
$(this).addClass('className'); // 클래스에 className 이 추가(기존 클래스 존재) $(this).addClass('className1 className2'); |
▤ 클래스 삭제 [removeClass]
$(this).removeClass('className'); // 클래스에 className 이 삭제(다른 클래스 그대로) $(this).removeClass('className1 className2'); |
▤ 클래스 변경 [attr]
$(this).attr('class','className'); // 클래스 이름이 className로 변경(기존 클래스 사라짐) |
▤ 클래스 토글 [toggleClass]
$('#subject').click(function(){ $(this).toggleClass('className'); } // 클래스 이름이 생겼다 사라지다를 반복 //※비슷하게 쓰이는 함수로 toggle() 이 있다.
|
▤ 클래스명 확인 [hasClass]
$(this).hasClass('className'); // 특정 클래스 포함 여부를 확인 $(this).hasClass('className1 clsssName2'); |
'웹개발 > jQuery' 카테고리의 다른 글
[jQuery] draggable - div 드래그 (0) | 2017.08.23 |
---|---|
[jQuery] 다중 select (0) | 2017.02.09 |
[jQuery] click에 따른 마우스 휠 on off (0) | 2017.02.07 |
[jQuery] click event scroll (0) | 2017.02.06 |
[jQuery] resize() - 브라우저 크기 변환시 호출 (0) | 2017.01.25 |