I would try: $("#myElement").before( "<div>new element</div>").remove(); 



-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of George Adamson
Sent: mercredi 31 janvier 2007 15:02
To: [email protected]
Subject: [jQuery] What is the best way to replace an element using JQuery?


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-JQuer
y--tf3148907.html#a8729470
Sent from the JQuery mailing list archive at Nabble.com.


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

-- 
Ce message Envoi est certifié sans virus connu.
Analyse effectuée par AVG.
Version: 7.5.441 / Base de données virus: 268.17.17/661 - Date: 30/01/2007
23:30
 


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

Reply via email to