That's what I was after - knew jQuery wouldn't disappoint!

Many thanks

George

On May 18, 1:08 pm, "Michael Price" <m...@edwardrobertson.co.uk>
wrote:
> You can use either:
>
> $("selector").text("New text");
> Or
> $("selector").html("New text");
>
> Both also work as getters if you don't provide an argument:
> theText = $("selector").text();
> theHTML = $("selector").html();
>
> Is this what you were after?
>
> Regards,
> Michael Price
>
> -----Original Message-----
> From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
>
> Behalf Of George
> Sent: 18 May 2009 12:09
> To: jQuery (English)
> Subject: [jQuery] Re: What's the best way to replace text in a node?
>
> Sorry, folks, I'm not using remove(), I'm using empty() - like this:
>
> JQUERY
> <p id='dText'>text to be replaced</p>
> $('#dText').empty().append('New text string')
>
> On May 18, 12:02 pm, George <george.bea...@googlemail.com> wrote:
> > I'm guessing this should be a simple one for the jQuery stalwarts
> > here.  I've recently moved over from Protoype and was used to using
> > the update() function to replace text within a node - something like
> > this:
>
> > PROTOTYPE
> > <p id='dText'>text to be replaced</p>
> > $('dText').update('New text string')
>
> > JQUERY
> > <p id='dText'>text to be replaced</p>
> > $('#dText').remove().append('New text string')
>
> > Now it appears to me that in jQuery, there isn't an out of the box
> > function to replace the contents of a node without also replacing the
> > node too, hence the reason I am chaining remove() and append().  Is
> > there a better way to achieve this?
>
> > Many thanks
>
> > George

Reply via email to