본문 바로가기

개발중/jQuery

next/prev (정)

728x90
반응형

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>test05.html</title>
    <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
    <link rel="stylesheet" href="/resources/demos/style.css">
    <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

    <script>
    $(function(){
        var style_1 = { //보라색
            'font-size':'20pt' ,
            'background-color':"#A9ABD7" ,
            'border':"5px solid #363A85"
        }

        var style_2 = { //분홍색
            'font-size':'20pt' ,
            'background-color':"#F0B4C7" ,
            'border':"5px solid #E587A5"
        }

        var style_3 = { //주황색
            'font-size':'20pt' ,
            'background-color':"#FFEEDA" ,
            'border':"5px solid #FFA43F"
        }

        var style_4 = { //초록색
            'font-size':'20pt' ,
            'background-color':"#BCD9BA" ,
            'border':"5px solid #045900"
        }

        $('.txt').prev().css(style_1);

        $('.txt + p').prev().css(style_2);

        $('.txt + p').css(style_3);

        $('.txt').next().next().css(style_4);

    });
    </script>

</head>
<body>

    <div id="wrap">
        <h1>인접관계 선택자 183p</h1>
        <p>내용1</p>
        <p class="txt">내용2</p>
        <p>내용3</p>
        <p>내용4</p>
    </div>

</body>
</html>
728x90
반응형

'개발중 > jQuery' 카테고리의 다른 글

선택자  (0) 2020.08.20
선택자  (0) 2020.08.20
jQuery tap메뉴 버튼 만들기  (0) 2020.07.26
JQUERY 메뉴 네비게이션바 만들기  (0) 2020.07.26
JQUERY CLASS  (0) 2020.07.26