How to change class in Jquery?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
21 views
I want when div(a) did not have the class js-hidden , there was something, as to do so would be code tracked the change permanent?
by | 21 views

3 Answers

0 like 0 dislike
Method only two: use setInterval() to constantly check the presence or absence of class js-hidden, but it's "mildly" not very nice and not at all an elegant solution. And the second option is to watch "who changes" (i.e. who caused) change the class and perform the necessary action at this moment.
by
0 like 0 dislike
Tell ID to this div for example target
var theClass = $('#target').attr('class'); if(theClass == "js-hidden"){ alert("this diva we need class"); }else{ alert("this diva class has been removed"); }
by
0 like 0 dislike
MutationObserver to help you
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
asked Jun 2, 2019 by RushV
0 like 0 dislike
1 answer
110,608 questions
257,187 answers
0 comments
40,796 users