<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script src ="../js/jquery-3.2.1.js"></script>
</head>
<style>
.item0{background:orange}
.item1{background:yellow}
.item2{background:pink}
</style>
<script>
$(function(){
//each()처럼 $() 갯수 만큼 돈다.
$('h1').addClass(function(index){
alert();
return 'item' + index;
})
})
</script>
<body>
<h1>Header-0</h1>
<h1>Header-1</h1>
<h1>Header-2</h1>
</body>
</html>
' sundries' 카테고리의 다른 글
3-6 attr() 콜백 함수 / 속성값 Object 사용 (0) | 2018.01.12 |
---|---|
3-4 attr() (0) | 2018.01.12 |
2-10 xml 문서 find 로 찾기 (0) | 2018.01.12 |
2-4 체이닝_필터 end() eq() add() hide() show() (0) | 2018.01.12 |
2-4 체이닝 (0) | 2018.01.12 |