[Selector.htm]



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

    <title>Selector : 선택자/선택기/실렉터/셀렉터</title>

    <script src="js/jquery-1.3.2-vsdoc2.js" type="text/javascript"></script>

    <style type="text/css">

        .bg { background-color:Yellow; }

        .horizontal { float:left; list-style:none; margin:10px; }

    </style>

    <script type="text/javascript">

        $(document).ready(

 

            function() {

 

                //[1] li > u 에 대해서 배경색을 Yellow로 설정

                $('li > u').addClass('bg'); // li 자식 요소 중 u 태그인것만 선별

 

                //[2] id 속성이 myFavorites인 것의 자식 요소중 li CSS 클래스 적용

                $("#myFavorites > li").addClass("horizontal");

 

                //[3] id 속성에 대해서 직접 접근

                jQuery('#jquery').click(function() { alert('jQuery'); });

               

                //[4] class 속성이 sil인 개체에 접근

                $('.sil').click(function() { alert('실버라이트'); });

            }

 

        );

    </script>

</head>

<body>

 

<h3>관심사항</h3>

<ul id="myFavorites">

    <li><u>C#</u></li>

    <li>ASP.NET</li>

    <li class="sil">Silverlight</li>

    <li id="jquery">j<u>Q</u>uery</li>

</ul>

 

</body>

</html>

 

 

 

 

 

 

<!-- 참고사항 : 

(.)클래스 / (#)아이디

-->





-------------------------------------------------------------------------------------




[실행결과]







Posted by holland14
: