I could see that being VERY slow....

$("p").each(function() {
   if ($(this).text()=='When the day......believing') {
      $(this).replaceWith('<span>chota</span>');
      return false
  }
})

....would work, but I wouldn't recommend it.

Anyway, why would you want to do this, and how would you manage to get the exact text that's going to be in the paragraph into the JavaScript ? If you have to edit the page to do that, why not just edit the paragraph itself ?

L

Sourabh wrote:
Hello all,

Below code works well for IE but not for firefox due to newlines
present in the html source.Can anybody help me making this work in
FF.It works well in IE6



 <html>
<head>
  <script src="http://code.jquery.com/jquery-latest.js";></script>

  <script>
  $(document).ready(function(){

    $("body").find("p:contains('When the day is short find that which
matters to you or stop believing')").replaceWith( '<span>chota</
span>' );

  });
  </script>

</head>
<body>
  <p>
    When the day is <span>short</span>
    find that which <b>matters</b> to you
    or stop believing
  </p>
</body>
</html>

Thanks in advance

Sourabh
------------------------------------------------------------------------


No virus found in this incoming message.
Checked by AVG - www.avg.com Version: 8.5.392 / Virus Database: 270.13.27/2258 - Release Date: 07/24/09 05:58:00


Reply via email to