<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<script type="text/javascript" src="../jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("div").filter(":even").not(".test").addClass("lightblue").end().end().eq(1).css("color","blue"); //:odd/:even (홀수번째 div에 lightblue적용)
//$(".test").filter("p").css("background","pink");
$(".test").each(function(){
if($(this).is("p")){
$(this).css("background","pink");
}
});
});
</script>
<style>
div { width:60px; height:60px; margin:10px; /*float은 정렬 방향. left - 왼쪽에서 오른쪽으로, 기본은 위에서 아래*/
border:2px solid blue ; }
.lightblue { background:lightblue; color:white;}
</style>
</head>
<body>
<div>1번</div>
<div>2번</div>
<div>3번</div>
<div>4번</div>
<div>5번</div>
<div>6번</div>
<hr>
<div class="test">가</div>
<div class="test">나</div>
<div class="test">다</div>
<p class="test">라</p>
</body>
</html>