如何在IE上创建xml元素并添加nodeValue

How to create xml element and add nodeValue on IE

本文关键字:元素 添加 nodeValue xml 创建 IE      更新时间:2023-09-26

我在IE10上收到js错误,试图创建一个xml节点并向nodeValue添加值。

错误:

This operation can not be performed with a node of type ELEMENT. 

法典:

var displayValueElement = this.properties.createElement("Property");
if ($.browser.msie)
{
    displayValueElement.nodeValue = "some value"; //error is here
}

该代码适用于Chrome和Firefox,但IE必须使用nodeValue。

displayValueElement.textContent = displayValue;

注意:this.properties是从parseXML()返回的xml文档

提前感谢您,如果需要更多说明,请告诉我。

我想

我可以求助于使用jQuery而不是原始的javascript...

$(displayValueElement).text(displayValue);