Valid XHTML 1.0 Transitional

Selecting the third/nth child

This is paragraph 1.

This is paragraph 2.

This is paragraph 3.

This is paragraph 4.

The jQuery codeCode START
        
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
    <script type="text/javascript">
      function setStyle1() {
        $('p:nth-child(3)').css("font-style","italic");
      }
      function setStyle2() {
        $('p:nth-child(3)').css("font-weight","bold");
      }
      function setStyle3() {
        $('p:nth-child(3)').css("font-size","larger");
      }
      function setStyle4() {
        $('p:nth-child(3)').css("color","#0000ff");
      }
    </script>
    
    <style type="text/CSS">
    <!--
        .code { color: red; }
        .back { background-color: yellow; }
    -->
    </style>
  </head>

  <body>
  <h1>Selecting the first and last children</h1>
  <div>
  <p>This is paragraph 1.</p>
  <p>This is paragraph 2.</p>
  <p>This is paragraph 3.</p>
  <p>This is paragraph 4.</p>
  </div>
  <form action="">
   <input type = "button" value="Select"onclick="setStyle1()"></input>
   <input type = "button" value="Select"onclick="setStyle2()"></input>
   <input type = "button" value="Select"onclick="setStyle3()"></input>
   <input type = "button" value="Select"onclick="setStyle4()"></input>
  </form>