Hey all,
I was wondering if any of you has done any thing allong the lines of
node wrapping? For example, lets same I have a document containing:
<span id="myElement">My element text</span>
And I want to wrap myElement with another node like this:
<div><span id="myElement">My element
text</span></div>
The only solution I found was to do something like this:
var myDiv = document.createElement (''div'');
$(''myElement'').parentNode.insertBefore (myDiv,
$(''myElement''));
myDiv.appendChild($(''myElement''));
Does anyone have a more elegant solution than this? Along the same
lines, a replace node method:
var myDiv = document.createElement (''div'');
$(''myElement'').parentNode.insertBefore (myDiv,
$(''myElement''));
Element.remove(''myElement'');
You can see actual working code of this if you like. It is a little
project I started working on:
http://thinkof.net/projects/js/magic_buttons/index.html
My wrap node method is here (at line 71):
http://thinkof.net/projects/js/magic_buttons/javascript/MagicButtons.js
As always, if you have suggestions feel free to make them. This code
is BSD lisence based.
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs