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 8451579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:16:46+00:00 2026-06-10T11:16:46+00:00

I am working on a full width jQuery slider. I’m stuck at the navigation.

  • 0

I am working on a full width jQuery slider.
I’m stuck at the navigation.
When I click on “1”, it goes to slider 1. on “2”, it goes to slide 2…and so on.
But I want the link color to change to #d45; when the link is active.
I tried adding a a.active class…but it does not seems to work.

Here’s my fiddle

Here’s my code :

HTML

<div class="slider">
    <div class="slide">1</div>
    <div class="slide">2</div>
    <div class="slide">3</div>
    <div class="slide">4</div>
</div>
<ul class="slider-nav">
    <li><a href="#" >1</a></li>
    <li><a href="#" >2</a></li>
    <li><a href="#" >3</a></li>
    <li><a href="#" >4</a></li>
</ul>
<div class="clear"></div>
<div class="content">
    <div class="wrapper">
        <p>Some site content will be here</p>
        <p>Some site content will be here</p>
        <p>Some site content will be here</p>
        <p>Some site content will be here</p>
        <p>Some site content will be here</p>
    </div>
</div>
<div class="footer">
    <div class="wrapper">&copy; www.mysite.com</div>
</div>​

CSS

.clear { clear:both; }
.wrapper { width:980px; margin:0 auto; }
.slider { margin:0 0; height:200px; position:relative;  }
.slider .slide { display:none; background:red; position:absolute; height:200px; width:100%; text-align:center; color:#fff; font-size:24pt; }
.header { background:#eee; font-size:18pt; }
.content { }
.footer { background:#eee; text-align:center; }

.slider-nav { margin: 0 auto; width:100px; clear:both; } 
.slider-nav li { float:left; margin:0 5px; }

.slider-nav li a.active { color:#d45; }
​

jQuery

$('.slider .slide:first').addClass('active').fadeIn(200);

function rotate(index) {
     $('.slider .slide.active').removeClass('active').fadeOut(200, function() { 
         $('.slider .slide:eq(' + index + ')').addClass('active').fadeIn(200);
     });   
}

$('.slider-nav li a').click(function() {    
    var index = $(this).parent().index('li');
    rotate(index);
    return false;
});

setInterval(function() {
    var $next = $('.slider .slide.active').next();

    if ($next.length == 0)
        $next = $('.slider .slide:first');

    rotate($next.index());
}, 2000);​

Any help would be appreciated.

Thank you

  • 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-06-10T11:16:47+00:00Added an answer on June 10, 2026 at 11:16 am

    See http://jsfiddle.net/5UYmu/3/

    $('.slider .slide:first').addClass('active').fadeIn(200);
    
    function rotate(index) {
         $('.slider .slide.active').removeClass('active').fadeOut(200, function() {
             $('.slider .slide:eq(' + index + ')').addClass('active').fadeIn(200);
         });   
    }
    
    $('.slider-nav li').click(function() {
        clearInterval(timer);
        $(this).siblings('.active').removeClass('active');
        $(this).addClass('active');
        var index = $(this).index('li');
        rotate(index);
        timer=setInterval(go, 2000);
        return false;
    });
    $('.slider-nav li:first').click();
    var timer=setInterval(go, 2000);
    function go() {
        var $next = $('.slider-nav li.active').next();
        if ($next.length == 0){
            $next = $('.slider-nav li:first');
        }
        $next.click();
    }
    

    It’s easier if you add the click event to '.slider-nav li' instead of '.slider-nav li a'.

    And in order to solve your problem, instead of showing the next .slide, you can click() the next <li> in .slider-nav.

    Moreover, I think it’s better if we clear the interval when the user clicks a navigation link. This way we avoid situations like:

    • t=0ms. Interval starts
    • t=2000ms. Next slide
    • t=3900ms. User click a navigation link
    • t=4000ms. Next slide
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a project calling for full email server integration. We want to
I'm working on a rather full-on site using jQuery (if the solution is not
some how i manage to have jquery transfer effect working with jquery dialog but
I am looking for a PHP PDO full working example with best practices for
I'm working on a new project with a full ANT build. I use eclipse
I have jqGrid 3.5 (full) mostly working. I have it retrieving data with the
I'm working on designing a full-page site, which will be powered mostly with javascript
I have implemented one matrix multiplication with boost::numeric::ublas::matrix (see my full, working boost code
Does anyone has the code to a full working example of slartoolkit ( http://slartoolkit.codeplex.com/
I am working on the Full Text Search in Sql Server 2005. I have

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.