【问题标题】:change innertext without affecting dom elements in Javascript (not jquery)更改内部文本而不影响 Javascript 中的 dom 元素(不是 jquery)
【发布时间】:2014-03-06 07:50:25
【问题描述】:

我需要在 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>

【问题讨论】:

标签: javascript html dom xul


【解决方案1】:

这完成了工作:

description.insertBefore(label,description.firstChild);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-08-01
    • 1970-01-01
    • 2011-11-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多