Valid XHTML 1.0 Transitional

jQuery: Selecting elements by contained text

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 setStyle() {
        $('p:contains("3")').css("font-style","italic");
      }
      function setStyle2() {
        $('p:contains("3")').css("font-style","normal");
      }
    </script>
    
    <style type="text/CSS">
    <!--
        .code { color: red; }
        .back { background-color: yellow; }
    -->
    </style>
  </head>

  <body>
  <h1>jQuery: Selecting elements by contained text</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 3/italicize" onclick="setStyle1()"></input>
   <input type = "button" value="Select 3/normal" onclick="setStyle2()"></input>
   
  </form>