更改innertext而不影响Javascript中的dom元素(不是jquery)
我在firefox扩展中需要这个,所以我不使用Jquery,以下是我的代码:更改innertext而不影响Javascript中的dom元素(不是jquery),javascript,html,dom,xul,Javascript,Html,Dom,Xul,我在firefox扩展中需要这个,所以我不使用Jquery,以下是我的代码: var label = document.createElementNS(XUL_NS, "label"); // create a new XUL label label.setAttribute("value", actionLabel); label.setAttribute("class", "label-title"); var description = document.createEleme
var label = document.createElementNS(XUL_NS, "label"); // create a new XUL label
label.setAttribute("value", actionLabel);
label.setAttribute("class", "label-title");
var description = document.createElementNS(XUL_NS, "description");
description.setAttribute("id", actionId);
description.appendChild(label);
description.innerHTML=actionText;
输出应为:
<description id=actionId> <label class="label-title" value=actionLabel/> This is a long section of text that will word wrap when displayed. </description>
这起到了作用:
description.insertBeforelabel,description.firstChild 您可以使用.innerText和/或.textContent,请参阅