如何更改标签并在 mootols 中设置 id?

How to change tag and also set id in mootols?

我有一个 DOM 结构,如下所示

<dt id="helloworld">Features</dt>

我想使用 mootools 像下面这样更改它

<div id="helloworld">Features</div>

怎么做?基本上第三个标签从 dt 变为 div?我是 mootols 的新手。你能给我举个例子吗?页面中只有helloWorld

下面我试过了

$$("#helloworld").each(function(el) {
     new Element("div", {
        html: el.get("html")
    }).replaces(el);
});

它确实取代了标签。但我也失去了 id :(

您也可以将 ID 作为 the element constructor 的 属性 传递:

$$("#helloworld").each(function(el) {
     new Element("div", {
        html: el.get("html"),
         id: el.get('id')
    }).replaces(el);
});

jsFiddle: https://jsfiddle.net/09tvfjdj/