You might try:

$("#myElement").remove().after("<div>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 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("<div>new
> element</div>")
>
> Depending on the circumstances I usually find I have to resort to DOM
> methods or if myElement has no siblings then I can use
> .parent().html("...").
>
> Any thoughts? Am I missing something?!
>
> Cheers
>
> George
> --
> View this message in context: 
> http://www.nabble.com/What-is-the-best-way-to-replace-an-element-using-JQuery--tf3148907.html#a8729470
> Sent from the JQuery mailing list archive at Nabble.com.
>
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>


-- 
---------
Bender: "Amy, you like cute things so I baked you a pony."
---------

http://www.reefs.org - Where reefkeeping begins on the internet.
http://www.advancedaquarist.com - High quality, free monthly publication for
the reef keeping hobbyist.
http://www.aquaristcourses.org - Distance learning courses for the
marine aquarist.

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to