cant you use

<span id="original">origanal html</span>' '<span class="new">html to
be replaced </span'>
$('#original').html ($('.new').html ());
$('#new').delete(); if you don need it anymore.


On 24 Lie, 15:56, Sourabh <sourabhmkulka...@gmail.com> wrote:
> Thanks for your help
>
> Ok I have  a scenario like this -
>
> I have an array with
>
> ['<span>origanal html</span>' ]['<span>html to be replaced </span'>]
>
> This array will be available to me when the page is loaded.
>
> Now I have a HTML page (DOM or DOM container element) in which I need
> to search the ['<span>origanal html</span>' ] and replace it with the
> ['<span>html to be
> replaced </span'>].
>
> This will apply to ANY HTML page . and  "HTML to find"  can be
> ANYTHING like "<b>I </b> am a <i>good</i> <span class=''foo">boy </
> span>"
>
> Is there any better way to do this ? I also tried to go for traversing
> dom but I was not able to do that
>
> On Jul 24, 4:48 pm, Liam Byrne <l...@onsight.ie> wrote:
>
> > 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