jQuery的附加功能在Internet Explorer 8中无法正常工作 [英] jQuery append function not working in Internet Explorer 8

查看:123
本文介绍了jQuery的附加功能在Internet Explorer 8中无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我的code -

  $(机构)追加(< D​​IV>中+
                        &所述; UL>中+
                            <立GT; +
                                < A HREF =JavaScript的:无效(0)的onclick ='加()'>添加< / A>中+
                            < /李>中+
                            <立GT; +
                                < A HREF =JavaScript的:无效(0)的onclick =编辑()'>编辑< / A>中+
                            < /李>中+
                            <立GT; +
                                < A HREF =JavaScript的:无效(0)的onclick =删除()'>删除< / A>中+
                            < /李>中+
                        &所述; / UL>中+
                    < / DIV>中);

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

 用户代理:Mozilla的/ 4.0(兼容; MSIE 8.0; Windows NT的5.1;三叉戟/ 4.0)
时间戳:星期三,2013年3月27日7时03分53秒UTC消息:HTML解析错误:无法修改子元素之前父容器元素被关闭(KB927917)
行:0
字符:0
code:0


解决方案

你需要做的这个页面加载完成后,(因为IE8需要时间来渲染和JavaScript被执行):

  $(文件)。就绪(函数()
{
   $(机构)追加(< D​​IV>中。+
                    &所述; UL>中+
                        <立GT; +
                            < A HREF =JavaScript的:无效(0)的onclick ='加()'>添加< / A>中+
                        < /李>中+
                        <立GT; +
                            < A HREF =JavaScript的:无效(0)的onclick =编辑()'>编辑< / A>中+
                        < /李>中+
                        <立GT; +
                            < A HREF =JavaScript的:无效(0)的onclick =删除()'>删除< / A>中+
                        < /李>中+
                    &所述; / UL>中+
                < / DIV>中);
});

Here is my code-

$("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>");

In IE8 I am getting following error - Webpage error details

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

解决方案

you need to do this after page load completed (because IE8 takes time to render and JavaScript get executed):

$(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>");
});

这篇关于jQuery的附加功能在Internet Explorer 8中无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆