Re: [jQuery] What is the best way to replace an element using JQuery?

2007-01-31 Thread Mike Alsup
> Yep, a replace() function would be nice. Here you go, world's smallest plugin: $.fn.replace = function(o) { return this.after(o).remove(); }; ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/

Re: [jQuery] What is the best way to replace an element using JQuery?

2007-01-31 Thread Alexandre Plennevaux
m flavours... -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of George Adamson Sent: mercredi 31 janvier 2007 18:14 To: discuss@jquery.com Subject: Re: [jQuery] What is the best way to replace an element using JQuery? Thanks for all your replies. Looks like everyone

Re: [jQuery] What is the best way to replace an element using JQuery?

2007-01-31 Thread George Adamson
Thanks for all your replies. Looks like everyone settled on a similar solution using before() or after() in combination with remove(). Yep, a replace() function would be nice. Shane - Just in case you don't already know about it, wrapInner() is available as a plugin at http://motherrussia.polyest

Re: [jQuery] What is the best way to replace an element using JQuery?

2007-01-31 Thread Andreas Wahlin
This is mostly a guess, but $('#element').after('new stuff').remove(); andreas On Jan 31, 2007, at 15:02 , George Adamson wrote: > > Despite having used JQuery for some time and also written plugins, > I've never > discovered a good way to replace one element with another. > > Just need someth

Re: [jQuery] What is the best way to replace an element using JQuery?

2007-01-31 Thread Brandon Aaron
You should be able to do something like this. $('#myElement').before('replacement').remove(); -- Brandon Aaron On 1/31/07, George Adamson <[EMAIL PROTECTED]> wrote: > > Despite having used JQuery for some time and also written plugins, I've never > discovered a good way to replace one element wi

Re: [jQuery] What is the best way to replace an element using JQuery?

2007-01-31 Thread Mike Alsup
> Despite having used JQuery for some time and also written plugins, I've never > discovered a good way to replace one element with another. > > Just need something like: $("#myElement").replaceWith("new > element") I usually do this: $("#myElement").after('new element').remove(); __

Re: [jQuery] What is the best way to replace an element using JQuery?

2007-01-31 Thread Shane Graber - jQuery
You might try: $("#myElement").remove().after("new element<\/div>"); It would be nice to have a replaceWith method and a wrapInner method in the core as I've found I need to be able to do this on a regular basis. FWIW, Shane On 1/31/07, George Adamson <[EMAIL PROTECTED]> wrote: > > Despite ha

Re: [jQuery] What is the best way to replace an element using JQuery?

2007-01-31 Thread Alexandre Plennevaux
I would try: $("#myElement").before( "new element").remove(); -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of George Adamson Sent: mercredi 31 janvier 2007 15:02 To: discuss@jquery.com Subject: [jQuery] What is the best way to repl

[jQuery] What is the best way to replace an element using JQuery?

2007-01-31 Thread George Adamson
Despite having used JQuery for some time and also written plugins, I've never discovered a good way to replace one element with another. Just need something like: $("#myElement").replaceWith("new element") Depending on the circumstances I usually find I have to resort to DOM methods or if myElem