Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/90.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
更改innertext而不影响Javascript中的dom元素(不是jquery)_Javascript_Html_Dom_Xul - Fatal编程技术网

更改innertext而不影响Javascript中的dom元素(不是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

我在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.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,请参阅