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
- 메소드
- mybatis
- 오버로딩
- JSP
- 이클립스
- oracle
- AWT
- 메서드
- Android
- 어노테이션
- 기본
- OGNL
- Java
- 국제화
- struts2
- 에러페이지
- Eclips
- 생성자
- 전화걸기
- 예외처리
- Graphic
- HTML
- layout
- paint
- 배열
- Menu
- JavaScript
- Spring
- 클래스
- 안드로이드
Archives
- Today
- Total
note
addClass()메서드 / addClass() 메서드의 콜백함수 본문
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<script src="http://code.jquery.com/jquery-1.7.js"></script>
<script>
$(document).ready(function (){
$('h1').addClass('item');
});
</script>
<body>
<h1>Header-0</h1>
<h1>Header-1</h1>
<h1>Header-2</h1>
</body>
</html>
소스를 보면 <h1>태그에 class="item" 으로 된걸 확인할 수 있다.
addClass() 메서드의 콜백함수
다른 클래스명을 줘야할때
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<script src="http://code.jquery.com/jquery-1.7.js"></script>
<script>
$(document).ready(function (){
$('h1').addClass(function(index){
return 'class' + index;
});
});
</script>
<body>
<h1>Header-0</h1>
<h1>Header-1</h1>
<h1>Header-2</h1>
</body>
</html>
class명이 순차적으로 늘어남
'JavaScript > jQuery' 카테고리의 다른 글
| attr()메서드 Getter / Setter / (0) | 2012.03.21 |
|---|---|
| removeClass()메서드 (0) | 2012.03.21 |
| XML 파싱 (0) | 2012.03.21 |
| is()메서드 (0) | 2012.03.21 |
| add()메서드 (0) | 2012.03.21 |