Martinez, Andrew a écrit :
> This example doesn't really use any of prototype's functionality beyond the $
> function, but it is still small enoguht. The first 3 lines are just setup
> lines, the last two specifically deal with attaching the elements to the DOM.
> I believe there is a function that will reproduce the 2nd to last line as a
> function call, but for the life of me I can't remember what it is named.
> Either way, typing out the actual code is just as fast (if not faster).
> -
> - var outerDiv = document.createElement( "DIV" );
> - outerDiv.id = "foo";
> - var innerDiv = $("stuff");
> -
> - innerDiv.parentNode.appendChild(outerDiv);
> - outerDiv.appendChild( innerDiv );
Almost. This could move the original div to an undue position. You'd
have to insert the new outer div at the same DOM position. You can do
this by merely changing the penultimate line to this:
innerDiv.parentNode.insertBefore(outerDiv, innerDiv);
That will do the trick.
--
Christophe Porteneuve a.k.a. TDD
"[They] did not know it was impossible, so they did it." --Mark Twain
Email: [EMAIL PROTECTED]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---