Why does jQuery's parents/closest(selector) functions behave differently in IE8?

旧巷老猫 提交于 2019-12-06 16:32:25

Do the top level elements have to be sections? It looks like you are running into one of the areas where the lack of support for HTML5 in IE8 is limiting you. If you change the sections to divs, the code works as is.

Section support in browsers.

Looking at the selectors in your jsFiddle, I was able to get it to work fine in IE8 if I just got rid of the second part of the selector.

$(document).ready( function(){
     $('a[data-detailed]').live('click', function(event){
        var a = $(this);
        var key= a.attr('data-detailed');

        $(".detailedOverview[data-detailed="+key+"]").slideToggle('fast');
        $(".masterOverview").slideToggle('fast');
        event.preventDefault();   
    });

    $('a[href=#back]').live('click', function(event){
        var a = $(this);
        var detailedOverview= a.parents("[data-detailed]");

        $(".masterOverview").slideToggle('fast');         
        detailedOverview.slideToggle('fast');

        event.preventDefault();   
    });
});

In each of your selectors you had a ", fileparent" after the selector. It is not necessary to specify the parent like this and getting rid of it works. In fact you can get rid of fileparent all-together.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!