On Sat, May 21, 2011 at 12:13 AM, Rolf -nl <[email protected]> wrote:
> You have Element.replaces that works like > newElement.replaces(oldElement) > But in my case I have an array of elements to replace one element. so > [elements].replace(oldElement) > > Isn't there a smarter way than this one: http://jsfiddle.net/nbmsj/ > it feels quirky this way > Nothing smarter on offer from me. With a slight edit in the output (cost: one more <span>) there may be other ways to write the same: http://jsfiddle.net/nbmsj/1/ the .adopt() came to mind when you asked the question; took it from there. Can't find anything in Core that could be faster than yours though (adopt() takes one more DOM call). AFAIK there's no DOM call to replace a node with a series of 'em, so you always end up with a loop like that, one way or another. Personally, I'd first combine all the stuff I want to inject into one (parent) node, then inject that tree in one, but that's clearly not in scope for your question. -- Met vriendelijke groeten / Best regards, Ger Hobbelt -------------------------------------------------- web: http://www.hobbelt.com/ http://www.hebbut.net/ mail: [email protected] mobile: +31-6-11 120 978 --------------------------------------------------
