gpt4 book ai didi

javascript - Jquery append() 函数在 IE11 中失败

转载 作者:行者123 更新时间:2023-12-02 23:27:22 25 4
gpt4 key购买 nike

我是Jquery 1.10.2版本。我的要求是在现有 xml 的特定节点添加一个 xml 节点。为此,我使用 Jquery append() 函数。它在 Chrome、Firefox 和 IE Edge 中工作正常,但在 IE11 中失败。

在 IE11 中出现以下错误:

Object doesn't support this property or method

下面是代码

var effectiveDate = document.getElementById("brokerEffDate").value;
var groupSummaryResponse = soapGetGroupSummary.responseXml.cloneNode(true);


var userProvidedEffDateNode = "<userProvidedEffDate>"+effectiveDate+"</userProvidedEffDate>";

if (groupSummaryResponse != null){
$(groupSummaryResponse).find('divisions').append(userProvidedEffDateNode);
$(groupSummaryResponse).find('division').each(function(){

if ($(this).children().get(6).innerHTML == ''){
$(this).find('GroupExpDt').text('12/31/9999')
}

});
}

我需要进行哪些更改才能使其在 IE11 中正常工作?

Node.appendChild 在我的情况下也不起作用。

最佳答案

两者都应该可以工作,但 IE 有时会阻止某些内容(如果从本地主机运行)。

<HTML>
<HEAD>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
</HEAD>
<BODY>

<input type="text" id="brokerEffDate" value="testing" />

<div id="divData1">test div1 </div>

<div id="divData2">test div2 </div>


<script>
var effectiveDate = document.getElementById("brokerEffDate").value;

var divData2 = document.getElementById("divData2");

var userProvidedEffDateNode = "<div>" + effectiveDate + "</div>";
var ele = document.createElement("div");
ele.innerHTML = effectiveDate;

$("#divData1").append(userProvidedEffDateNode);
divData2.appendChild(ele);

</script>
</BODY>
</HTML>

允许被阻止的内容 Allow the blocked content

结果。大多数情况下,仅当您从本地主机运行时才会遇到此问题 Result

关于javascript - Jquery append() 函数在 IE11 中失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56680414/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com