D
D
DeniSidorenko2018-02-06 21:35:02
JavaScript
DeniSidorenko, 2018-02-06 21:35:02

How to track class change?

Good afternoon, there is such a problem, with such markup

<div class='wrapper'>
<div class='item'>
<div class='item'>
<div class='item active'>
<div class='item'>
</div>

When swiping another element, the item class changes (that is, hanging a handler in another place is not an option), I need to track the class change, and as soon as it has changed, get the index of a new element with the active class
. I don’t think this is even possible, but I decided to ask anyway: )

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stalker_RED, 2018-02-06
@DeniSidorenko

This can be tracked using MutationObserver .
But I would look for an opportunity to cling to the code that this class changes.

A
Ainur Valiev, 2018-02-07
@vaajnur

var mc = new Hammer(document.body);
        mc.on("swipe" , function(){
      $('.wrapper .item').each(function(k, v){
        if($(v).hasClass('active'))
          console.log(k)
      })
    })

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question