开发者

Jquery Fade In/Out Div Switcher Won't Display Right in IE

开发者 https://www.devze.com 2023-01-06 03:16 出处:网络
Basically how this is supposed to work (and does in firefox, safari, and chrome) is that there are three links in a list and when you click one, its class is used to find a div with the same name but

Basically how this is supposed to work (and does in firefox, safari, and chrome) is that there are three links in a list and when you click one, its class is used to find a div with the same name but in an id. That div is then faded in after all divs with a certain class are faded out (this div has to class as well as a catch all).

here is the JS code:

$(".dynamic_nav li a").click(function() {

    column_switch = $(this).parent().attr('class');

    if($(this).hasClass('active_tab') == true) {
        return false;
    }

    else {
        $(".dynamic_nav li a").removeClass("active_tab");

        $("div.portfolio_section").hide();

        $("#" + column_switch).fadeIn(500);

        $(this).addClass("active_tab");
    }

    return false;
});

And my html code:

<ul class="dynamic_nav">
    <li class="web"><a class="active_tab" href="#">Web</a></li>
    <li class="print"><a href="#">Print</a></li>
    <li class="advertising"><a href="#">Advertising</a></li>
</ul>

<div id="web" class="portfolio_section"><p>Some Text<p></div>
<div id="print" class="portfolio_section"><p>Some Text<p></div>
<div id="advertising" class="po开发者_JS百科rtfolio_section"><p>Some Text<p></div>


Ok so here are a few things I noticed that were wrong with the code you posted. After I fixed these it did work in IE.

First your advertising div is missing a closing quote after the class name. Second your li's all are using the same name which is probably something you are aware of already since you said it worked in others. I would check the missing quote to start. Because like I said it is working for me.

0

精彩评论

暂无评论...
验证码 换一张
取 消