gpt4 book ai didi

JQuery:html() 未按预期工作

转载 作者:行者123 更新时间:2023-12-01 07:31:31 24 4
gpt4 key购买 nike

我有一个div:

<div id="pageMessagesBox"></div>

在java脚本函数中,我试图在我的div中添加一些项目:

$("#pageMessagesBox").html("<a id='id'></a>");

但是我得到了 $("#pageMes​​sagesBox").html() 的以下结果:

"<A id=id></A>"

预期是:

"<A id='id'></A>"

我在这里做错了什么?

最佳答案

来自jquery documentation

This method uses the browser's innerHTML property. Some browsers may not return HTML that exactly replicates the HTML source in an original document. For example, Internet Explorer sometimes leaves off the quotes around attribute values if they contain only alphanumeric characters.

关于JQuery:html() 未按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5777906/

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