HTML
위젯의 요소 노드 이름을 변경할 수 없습니다. 그러나 Document.get().createElement("mydiv")
으로 자신의 태그를 만들고이를 사용하여 Composite
을 확장하여 Widget
을 새로 만들 수 있습니다. 그러나 DOM에 새 태그를 추가하고 HTML을 확장하면 원하는 내용으로 들리지 않으므로 이유를 모르겠습니다. innerText
과 같은 메소드를 통해이 태그의 콘텐츠를 설정하는 것은 유효한 태그에만 사용할 수 있기 때문에 불가능합니다. 내용을 유지하고, 예를 들어
function changeTagName(elm,new_tag_name){
var newElm = document.createElement(new_tag_name)
var atr = elm.attributes;
for(var i=0;i<atr.length;i++){ // copy all atributtes
newElm.setAttribute(atr[i].name,atr[i].value)
}
document.body.insertBefore(newElm,elm)
newElm.innerHTML=elm.innerHTML; //copy the content
elm.parentNode.removeChild(elm) // remove original
}
속성