.text('some text') or .html('<some>html</some>') ?

On May 18, 7:08 am, George <george.bea...@googlemail.com> wrote:
> 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