JQUERY 4

by duckduck0054

HTML

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
  </head>
  <body>
    <h5>인접 관계 선택자(parent, children, prev, next, siblings)</h5>
    <ul id="wrap">
      <li>내용2</li>
      <li class="second">내용3</li>
      <li>내용4</li>
      <li>내용5</li>
    </ul>
  </body>
  <script type="text/javascript">
  	$(document).ready(function(){
    	//$(".second").parent().css("background-color", "aqua").css("width", "200px");
      //$("body").children().css("border","1px solid red").css("width","300px");
      //$(".second").prev().css("border","1px solid red").css("width","200px");
      //$(".second").next().css("background-color", "red");
      $(".second").siblings().css("background-color", "blue")
    });
  </script>
</html>