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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:47:44+00:00 2026-06-16T05:47:44+00:00

I want to add class .active to my custom bootstrap pagination. Currently it works

  • 0

I want to add class .active to my custom bootstrap pagination.

Currently it works good when I navigate by clicking the pagination, but if i use the arrows the next item in my pagination doesn’t get active.

So, basically I want to see which child-element of the .carousel element is active, and add the class active to the same (for example second) child element in my pagination.

$('.sb-links a').click(function(q){
  q.preventDefault();
  targetSlide = $(this).attr('data-to')-1;
  $('#myCarousel').carousel(targetSlide);
  $('a').removeClass('active');
  $(this).addClass('active').siblings().removeClass('active');
});

The code would look something like this, but its not even working if i type the child element manually.

if ( $('.carousel-inner div:nth-child(1)').hasClass('active') ) {
  $('.sb-links a:nth-child(1)').addClass('active');
};

Thanks in advance for help!

  • 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-16T05:47:45+00:00Added an answer on June 16, 2026 at 5:47 am

    Try:

    // calculate the index you want
    var index = 1; 
    // get the div at the calculated index
    var nthDiv = $('.carousel-inner div').eq(index);
    
    // check if div has class
    if (nthDiv.hasClass('active')) {
        // add class to the hyperlink at the same index
        $('.sb-links a').eq(index).addClass('active');
    }
    

    Here is a more complete solution:

    // attach an event which is triggered when transition is complete
    $('#myCarousel').on('slid', function (e) {
        // get the index of the current frame
        var index = $('.carousel-inner div').index('.active');
        // get all the slider buttons
        var buttons = $('.sb-links a');
        // remove the 'active' class on all slider buttons
        buttons.removeClass('active');
        // add the 'active' class on the button corresponding to the current frame
        buttons.eq(index).addClass('active');
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to add a class of active to the ul and this following
In twitter bootstrap js tabs i have to add a class active to a
I want to add the active class to all the main category block in
I want to add a class to a link when it is clicked, but
I want to add class active to the <li> whenever specific url is accessed?
I want to add class atttributes to a superclass dynamically. Furthermore, I want to
I want to add a class to certain input or label elements in a
I want to add a class to multiple span elements with common classname's based
I have 2 list and i want to add a class =last to the
I am working on a Jquery accordion stuff. I want to add a class

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.