When you click to add and remove a class?


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
13 views
How to jquery implement a scheme: When you click on li add class = color (styles will be in advance of this class prescribed property). When you click on the next li, the previous class is deleted and assigned a color on which you clicked.
by | 13 views

2 Answers

0 like 0 dislike
$('li').click(function(){ $('li.color').removeClass('color'); $(this).addClass('color'); });
by
0 like 0 dislike
$('li').on('click', function() { $(this).addClass('active') .siblings().removeClass('active'); })
https://jsfiddle.net/zm2c5vsj/
by

Related questions

0 like 0 dislike
1 answer
asked Jun 10, 2019 by Breeze1
0 like 0 dislike
1 answer
asked Apr 13, 2019 by Breeze1
0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
asked Jun 1, 2019 by angry_yum
110,608 questions
257,186 answers
0 comments
35,456 users