jQuery日本語リファレンス

jQuery does not mean Japanese Query...

Traversing/API/jQuery - Sample Code

andSelf()


	        
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <script src="/jquery/js/jquery.js"></script>
  <script>
  $(document).ready(function(){
    $("div").find("p").andSelf().addClass("border");
    $("div").find("p").addClass("background");
  });
  </script>
  <style>
  p, div { margin:5px; padding:5px; }
  .border { border: 2px solid red; }
  .background { background:yellow; }
  </style>
</head>
<body>
  <div>
    <p>First Paragraph</p>
    <p>Second Paragraph</p>
  </div>
</body>
</html>
            
	      
[実行結果]
[andSelf() の説明へ]