Valid XHTML 1.0 Transitional

Selecting only direct descendants

This is paragraph 1.

This is paragraph 2.

This is paragraph 3.

This is paragraph 4.

This is paragraph 5.

The jQuery codeCode START
    
    <script type="text/javascript" src="./jquery-1.5.1.js"></script>
    <script type="text/javascript">
      function setStyle() {
        $('div > p').css("font-style", "italic");
      }
      
      function setStyle2() {
        $('div > p').css("font-style", "normal");
      }
    </script>
    
    <style type="text/CSS">
    <!--
        .code { color: red; }
        .back { background-color: yellow; }
    -->
    </style>
    
  </head>

  <body>
  <h1>Selecting only direct descendants</h1>
  <div>
    <blockquote>
      <p>This is paragraph 1.</p>
    </blockquote>
  <p>This is paragraph 2.</p>
  <p>This is paragraph 3.</p>
  <p>This is paragraph 4.</p>
  </div>
  
  <p>This is paragraph 5.</p>
  
  <form action="">
   <input type = "button" value="Select" onclick="setStyle()"></input>
   <input type = "button" value="Select (reset normal style)" onclick="setStyle2()"></input>
  </form>