Reputation: 3302
I have an element as below
<div id="menu">
<dl>
<dt>Features</dt>
<dd>
... Menu elements
</dd>
</dl>
</div>
I need to copy the word $$(#menu dt")
aka Features into another location after h1 where it is like
w4 ... h1 ...Features
Also I need to add a class to this new element.
I tried using
$$("#menu dt").inject($$("#w4 h1")[0],'after');
It does copy the element and put to the new location. However, I also lose the old element, aka the old element vanishes. I just want to copy not move.
Upvotes: 1
Views: 67
Reputation: 28837
You can get the text with el.get('text');
and then add that to 'w4 h1'
with a setter. Something like:
$$("#menu dt").each(function (el) {
var text = el.get('text');
document.getElement('w4 h1').set('html', text);
});
Upvotes: 1
Reputation: 692
I don't know what's your Mootools version but there are appendText and appendHTML functions availables: http://mootools.net/core/docs/1.5.1/Element/Element#Element:appendHTML
Upvotes: 1