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
<!DOCTYPE HTML>
<html lang="ko">
<head>
<meta charset="utf-8">
<script src="./js/jquery.js"></script>
<style>
    .box {
        width:100px;
        height:100px;
        border: 1px solid #000;
    }
</style>
</head>
<body>
    <div class="box">
        <div>
            <p></p>
        </div>
    </div>
    <div class="box">
        <div>
            <p class="foo"></p>
        </div>
    </div>
    <div class="box">
        <div>
            <p></p>
        </div>
    </div>
    <script>
 
        // $( ".box:has(.foo)").css("border", "3px solid red");  //box클래스중 foo클래스를 자식으로 가지고 있는 div선택
        $( ".box").has('.foo').css("border""3px solid red");  
 
    </script>
</body>
</html>


반응형
Posted by 힘없는염소