开发者

changing a banner ad based on visible tab

I got some help on this today, but had to modify it and need to clean it up. basically I have a tabbed interface and I need to show the appropriate banner ad based on what tab is visible. There are only two groups, brokers and all ot开发者_开发知识库hers. So if the broker tab (#BrokContent) is selected (both on page load and when you click it when another tab is visible) show the broker banner. All other times show the other banner.

HTML - the banner ads

<div id="brokerAd">
    <h3 class="featured">Featured PARTNER</h3>
    <div class="bannerTop">Im the broker banner
    <!-- brokerAd End --></div>
<!-- /bannerContain --></div>

<div id="bannerContain">
    <h3 class="featured">Featured PARTNER</h3>
    <div class="bannerTop">Other banners
    <!-- AdSpeed.com End --></div>
<!-- /bannerContain --></div>

and the JS that needs simplifying

if ($("#BrokContent").is(":visible")) {
          $("#brokerAd").show();
          $("#bannerContain").hide();
        } else {
          $("#bannerContain").show();
          $("#brokerAd").hide();
        }

        $("ul#flowtabs li a").click(function(){
            var bcVisible = $("#BrokContent").is(":visible");
            $("#brokerAd").toggle(bcVisible);
            $("#bannerContain").toggle(!bcVisible);
        });


I read through it briefly and I can't find any way to make it more concise. The only thing I can think is to remove the check for isvisible on the #brokContent in the click handler, and just leave the toggle() plain. Other than that, I think that's about it.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜