gpt4 book ai didi

javascript - jQuery append 功能在 Internet Explorer 8 中不起作用

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

这是我的代码-

$("body").append("<div>" +
"<ul>" +
"<li>" +
"<a href='javascript:void(0)' onclick='add()'>Add</a>" +
"</li>" +
"<li>" +
"<a href='javascript:void(0)' onclick='edit()'>Edit</a>" +
"</li>" +
"<li>" +
"<a href='javascript:void(0)' onclick='delete()'>Delete</a>" +
"</li>" +
"</ul>" +
"</div>");

在 IE8 中我收到以下错误 -网页错误详细信息

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)
Timestamp: Wed, 27 Mar 2013 07:03:53 UTC

Message: HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917)
Line: 0
Char: 0
Code: 0

最佳答案

您需要在页面加载完成后执行此操作(因为 IE8 需要时间来渲染并执行 JavaScript):

$(document).ready(function()
{
$("body").append("<div>" +
"<ul>" +
"<li>" +
"<a href='javascript:void(0)' onclick='add()'>Add</a>" +
"</li>" +
"<li>" +
"<a href='javascript:void(0)' onclick='edit()'>Edit</a>" +
"</li>" +
"<li>" +
"<a href='javascript:void(0)' onclick='delete()'>Delete</a>" +
"</li>" +
"</ul>" +
"</div>");
});

关于javascript - jQuery append 功能在 Internet Explorer 8 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15653424/

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