简体   繁体   English

IE7和8用jQuery的.slice抛出错误

[英]IE7 & 8 throwing errors with jQuery's .slice

The following code works great on other browsers, but on IE7 & 8 it complains about it: 以下代码在其他浏览器上运行良好,但在IE7和8上它抱怨它:

    var divs = $(".paginate-boxes li");
        for(var i = 0; i < divs.length; i+=9) {
          divs.slice(i, i+9).wrapAll("<li class='slide-portfolio'><ul></ul></li>");
        }

The code that it's working on is a long list of li s like so: 它的工作的代码是一个长长的清单li就像这样:

                        <li>
                                <!--Fade-->
                                <div class="mosaic-block fade">
                                    <a href="http://www.example.com/destination/" class="mosaic-overlay">
                                        <object class="details">

                                            <h4>Destination Page</h4>
                                            <p>
                                                                                                </p>
                                        </object>
                                    </a>
                                    <div class="mosaic-backdrop"><img width="296" height="175" src="http://www.example.com/wp-content/uploads/this_thumb.jpg" class="attachment-portfolio-image wp-post-image" alt="this_thumb" title="This image" /></div>
                                </div>
                            </li>

Using the Dev tools in IE9 (in 8 mode), I found that it complains when it gets to the .slice bit of the code, referencing this bit of jQuery (v.1.7.2) 使用IE9中的开发工具(在8模式下),我发现当它到达代码的.slice位时会.slice抱怨,引用这个jQuery(v.1.7.2)

// IE6-8 fail to clone children inside object elements that use
// the proprietary classid attribute value (rather than the type
// attribute) to identify the type of content to display
if ( nodeName === "object" ) {
    dest.outerHTML = src.outerHTML;
}

Not sure exactly what that means tbh 不确定这意味着什么

What do I need to change to stop it throwing an error, and why? 我需要更改什么来阻止它抛出错误,为什么?

回想起来相当明显 - 用<div>替换<object> <div> ,它工作正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM