2016년 10월 4일 화요일

[Ajax강의,jQuery강의,자바강의★탑크리에듀]jquery 강좌 기본 필터링 메소드 filter()

filter() 메서드 : 문서 객체에 대한 필터링
$(‘selector’).filter();                 $(‘seletor’).filter(function (index) {});
 
 
 
<html>
<head>
<meta charset="utf-8"/>
<script src="/ajaxjquery/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('h3:even').css( {
backgroundColor: 'Black',
color: 'White'
});
alert(1);
$('h3').filter(':even').css ({
backgroundColor: 'Green',
color: 'White'
});
 
alert(2);
$('h3').filter(function (index) { 
return index%2 == 0;
}).css({
backgroundColor: 'Yellow',
color: 'Black'
});
alert(3);
$('h3').css('background', 'orange').filter(':even').css('color','red');
}); </script>
<body>    
<h3>오라클자바커뮤니티</h3>
<h3>오라클자바커뮤니티프로그래밍실무학원</h3>
<h3>오라클자바커뮤니티시스템즈</h3>
<h3>오라클자바커뮤니티</h3>
<h3>OnJ</h3>
</body>
</html>

 
j19.png
j20.png
j17.png
j18.png

댓글 없음:

댓글 쓰기