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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8">
<style>
    div {
        background:green;
        width : 100px;
        height: 100px;
        line-height:100px;
        text-align:center;
        float:left;
        margin-right: 20px;
    }
</style>
<script src="./js/jquery.js"></script>
 
</head>
<body>
    <div class="box1">
        <div>1</div>
        <div>2</div>
    </div>
    <div class="box2">
        <div>3</div>
        <div>4</div>
    </div>
    <div class="box3">
        <div>5</div>
        <div>
            <!-- W3의 HTML 4.01 스펙부터 p 태그는 inline 요소만을 자식으로 가질 수 있다  -->            
            <p><span>6</span></p>
        </div>
    </div>
    <script>
 
        /*
         제한 선택자
        - jQuery 함수는 두번째 매개변수를 가질 수도 있습니다.
        - 이 매개변수는 어떤 컨텍스트에서 selector 를 찾아야 하는지에 대한 범위를 제한해 준다. (두번째 매개변수 안에서 selector를 찾는다.)
        */
        $('div''.box3').css({
            'background':'red'
        });
        
        $('span''.box3').text("변경");
        
    </script>
</body>
</html>


반응형
Posted by 힘없는염소