title: Set carousel custom button to active when slide is active
body: <p>I have a classic bootstrap carousel but with some modifications. Basically as you can see by the image below, I have a carousel of chart images. On top of the carousel there is another row with the custom select buttons(sales and tickets). 
  <a href="https://i.stack.imgur.com/giaaT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/giaaT.png" alt="enter image description here"></a></p>
  
  <p>The problem is that I want to add the active class to the button connected to that slide. Below I provide images of both html and jquery.
  HTML
  <a href="https://i.stack.imgur.com/URvQZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/URvQZ.png" alt="enter image description here"></a></p>
  
  <p>Jquery
  <a href="https://i.stack.imgur.com/nzbez.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nzbez.png" alt="enter image description here"></a></p>
  
  <p>Code for HTML</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$('#carousel-example-generic').on('slid.bs.carousel', function (event) {
              var nextactiveslide = $(event.relatedTarget).index();
              var $btns = $('.custom-carousel-btns');
              var $active = $btns.find("[data-slide-to='" + nextactiveslide + "']");
              // alert( nextactiveslide );
              $btns.find('.car-ind').removeClass('active');
              $active.find('.car-ind').addClass('active');
          });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>/* Charts Carousel */
  .carousel-inner &gt; .item &gt; img{
    margin: 0 auto;
  }
  
  .car-ind{
    color: grey;
  }
  
  .custom-carousel-btns .active{
    color: black;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/&gt;
  &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"&gt;&lt;/script&gt;
  
  
  &lt;div class="panel panel-default"&gt;
    &lt;div class="panel-heading"&gt;
      &lt;h3 class="panel-title"&gt;&lt;i class="fa fa-long-arrow-right fa-fw"&gt;&lt;/i&gt; Reports&lt;/h3&gt;&lt;img src="" class="img-responsive panel-img"&gt;
    &lt;/div&gt;
    &lt;div class="panel-body"&gt;
      &lt;!-- Carousel Controls --&gt;
      &lt;div class="row" style="border-bottom: 1px solid #eee; padding-bottom: 10px;"&gt;
        &lt;div class="col-sm-2 custom-carousel-btns"&gt;
          &lt;span&gt;&lt;a href="#carousel-example-generic" class="car-ind active" role="button" data-slide-to="0"&gt;Sales&lt;/a&gt;&lt;/span&gt;
          &lt;span&gt;&lt;a href="#carousel-example-generic" class="car-ind" role="button" data-slide-to="1"&gt;Tickets&lt;/a&gt;&lt;/span&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="row"&gt;
        &lt;div id="carousel-example-generic" class="carousel slide" data-ride="carousel" data-interval="false"&gt;
          &lt;!-- Wrapper for slides --&gt;
          &lt;div class="carousel-inner" role="listbox"&gt;
            &lt;div class="item active"&gt;
              &lt;img src="http://via.placeholder.com/350x150" class="img-responsive" style="width: 100%; height: auto;" alt="..."&gt;
            &lt;/div&gt;
            &lt;div class="item"&gt;
              &lt;img src="http://via.placeholder.com/350x150" class="img-responsive" style="width: 100%; height: auto;" alt="..."&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Thank you in advance</p>