Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7039453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:48:00+00:00 2026-05-28T01:48:00+00:00

I currently have jquery Cycle running on a page, but not only find it

  • 0

I currently have jquery Cycle running on a page, but not only find it bulky but it’s messing with the rest of my page. I’m writing a simple script to make it obsolete for my purposes, which will take the href of a menu item that is clicked, show the div that pertains to it, while hiding all others.

jsFiddle: http://jsfiddle.net/THuST/

HTML (Ignore the fact that I’ve used <ul> for just one <li> element – there are heaps more that will go in there but for simplicity I’ve omitted them)

<div id="adSlideshow">
    <div class="adSlideBox current" id="red">
        <ul class="gallery" id="redGallery">
            <li><img src="http://i.imgur.com/LMHtk.png" alt="Asics Folio Slide 1" title=""/></li>
        </ul>
    </div>
    <div class="adSlideBox" id="yellow">
        <ul class="gallery" id="yellowGallery">
            <li><img src="http://i.imgur.com/X25M3.png" alt="Plants Plus Folio Slide 1" title=""/></li>
        </ul>
    </div>
    <div class="adSlideBox" id="blue">
        <ul class="gallery" id="blueGallery">
            <li><img src="http://i.imgur.com/WyDQI.png" alt="" title=""/></li>
        </ul>
    </div>
</div>
<ul id="menu" style="list-style:none">
    <li><a href="#asics">RED</a></li>
    <span>\</span>
    <li><a href="#plants">YELLOW</a></li>
    <span>\</span>
    <li><a href="#tooheys">BLUE</a></li>
</ul>

CSS

.adSlideBox {display:none;}
.adSlideBox.current {display:block;}

img {max-width:350px; max-height:350px}

#menu li {float:left; margin-left:2em}

jQuery

$("#menu a").click(function() {
        var link = $(this).attr('href');
        var showIt = $(".adslidebox a[href=" + link + "]");
        var hideIt = $(".adSlideBox.current");

        hideIt.fadeOut(100, function(){
            hideIt.removeClass("current");
            showIt.addClass("current");
            showIt.fadeIn(100);
        });
    });

This is my first try at making a script from scratch, so please bear with me. I think I’m relatively close; the .current div fades out successfully, however the selected div doesn’t fade in, and the .current class isn’t toggled.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:48:01+00:00Added an answer on May 28, 2026 at 1:48 am

    Just a slight change to your html and javascript should solve the problem.

    http://jsfiddle.net/THuST/3/

    Basically, I made the ID’s of your divs match your href values. This way you just need to pull out the href value from your links and pass it into jQuery as a valid selector.

    JavaScript

    $("#menu a").click(function() {
            var link = $(this).attr('href');
            var showIt = $(link);
            var hideIt = $(".adSlideBox.current");
    
            hideIt.fadeOut(100, function(){
                hideIt.removeClass("current");
                showIt.addClass("current");
                showIt.fadeIn(100);
            });
        });
    

    HTML

               <div id="adSlideshow"><!-- DIV FOR THE AD BLOCK -->
    
                    <div class="adSlideBox current" id="asics">
                        <ul class="gallery" id="redGallery">
                             <li><img src="http://i.imgur.com/LMHtk.png" alt="Asics Folio Slide 1" title=""/></li>
                        </ul>
                    </div>
                    <div class="adSlideBox" id="plants">
                                <ul class="gallery" id="yellowGallery">
                                    <li><img src="http://i.imgur.com/X25M3.png" alt="Plants Plus Folio Slide 1" title=""/></li>
                                </ul>
    
                    </div>
                    <div class="adSlideBox" id="tooheys">
    
                                <ul class="gallery" id="blueGallery">
                                    <li><img src="http://i.imgur.com/WyDQI.png" alt="" title=""/></li>
    
                                </ul>
    
    
                    </div>
                </div>
    
    
    <ul id="menu" style="list-style:none">
    
        <li><a href="#asics">RED</a></li>
        <span>\</span>
        <li><a href="#plants">YELLOW</a></li>
        <span>\</span>
        <li><a href="#tooheys">BLUE</a></li>
    </ul>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a fancy web page with lots on JQuery included. Currently i am
I have this page that displays pictures in a div. I have jquery cycle
I currently have a single jQuery script page that I include in my ScriptManager
I am currently using jQuery cycle to display featured projects. I currently have the
I'm currently using this jQuery Cycle Plugin: http://jquery.malsup.com/cycle/ And I have the following code:
**I currently have this jQuery drop menu working fine but I'm wanting the parent
I currently have this jquery but it won't work. if it helps my url
I currently have a site that uses the JQuery cycle plugin. The site uses
Is there a better way to do this jquery code? Currently I have to
I have the jQuery numberformatter-plugin installed, but don´t get it to work correctly. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.