【问题标题】:IE8 HTML5 elements within cloned parent elements are not recognised无法识别克隆的父元素中的 IE8 HTML5 元素
【发布时间】:2014-09-25 09:17:39
【问题描述】:

我正在使用 html5shiv 来启用 HTML5 元素的样式。

当我克隆具有 HTML5 子元素的非 HTML5 元素(并且仅是非 HTML5 元素)时,IE8 无法识别该子元素。

在下面的例子中,第一部分是粉红色的,而克隆版本不是。

<!doctype html>
<html>
<head>      
    <style>
        div section { background:#f0f; display:block; }
    </style>

    <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="//code.jquery.com/jquery-1.11.1.min.js"></script>

    <script>
        jQuery(function ($) {
          $('#article').append($('div').clone());
        });
    </script>
</head>
<body>
    <article id="article">
        <div><section>This section should have a pink background.</section></div>
    </article>
</body>
</html>

jsbin 示例:http://jsbin.com/yuqeriwoxeqa/1/

【问题讨论】:

    标签: jquery html internet-explorer-8 html5shiv


    【解决方案1】:

    这是 IE8 本身不支持 html5 元素的结果。尝试以下两种解决方案之一:

    $('#article').append($('div').get(0).cloneNode());http://pastie.org/935834

    【讨论】:

      猜你喜欢
      • 2014-12-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-26
      • 1970-01-01
      相关资源
      最近更新 更多