How can I count the number of times a class of my html element changes?

1

The case is as follows:

I have 3 elements of the type div that makes a carousel with boostrap and in those divs there is a default class called item and when the div is selected or visible to that item another class is added which is called active, what I want to do is count the times that each of my items items came to contain the active class.

HTML code:

    <div id="carousel" class="carousel slide" data-ride="carousel">
            <div runat="server" id="CarouselHtml" class="carousel-inner" style="height: 500px;">
Aquí se genera el código de los slides con la clase item
            </div>
            <a href="#carousel" ID="tagLeft" onclick="waitchange();" class="left carousel-control" data-slide="prev">
                <span class="glyphicon glyphicon-chevron-left"></span>
            </a>
            <a  href="#carousel" ID="tagR" class="right carousel-control" onclick="waitchange();";  data-slide="next">
                <span class="glyphicon glyphicon-chevron-right" ></span>
            </a>
        </div>

The html code that are the divs with the item classes are generated by C #

    
asked by David 03.08.2018 в 22:14
source

1 answer

0

You can bin the slid event;

$('#carousel').bind('slid', function() {
    var indexSel_ = $('div.active').index() + 1;

slide

  

slid.bs.carousel: Occurs when the carousel has finished sliding from one item to   another   slide.bs.carousel Occurs when the carousel is about to   slide from one element to another.

slide:

  

slide.bs.carousel Occurs when the carousel is about to slide from one   item to another.   slide.bs.carousel Occurs when the carousel is about to slide from one element to another.

Reference: link

    
answered by 03.08.2018 в 22:52