javascript - Remove class added after clicking new button -
After clicking Help was adjusted to create a jQuery to change the orbit of the button but I think You need to click on a new button class that has been removed from others
I am trying but I can not I have tried somehow, but whenever I try I can remove all, and I can click that button Programming was not even with the new class.
Can anyone help me?
$ {Document> $ (document) .ready (function () {$ ('div # filter-container button'.) Click (function () {var id_button = $ (this) .val (); $ ("#" + Id_button + "") .addClass ("cbp-filter-item-active");})}}); .cbp-filter-item-active {background-color: # 5d5d5d; Color: #fff! Important; Border color: # 5d5d5d} & lt; Script src = "https: //ajax.googleapis com / ajax / libs / jQuery / 1.11.1 / jquery.min.js" & gt; & Lt; / Script & gt; & Lt; Div id = "filter-container" & gt; & Lt; Button value = "0" id = "0" href = "videos2-carrega.asp"> Todos & lt; / Button & gt; & Lt; Button value = "1" id = "1" href = "videos2-carrega.asp? Cat = 1" & gt; FamÃlia & lt; / Button & gt; & Lt; Button value = "2" id = "2" href = "videos2-carrega.asp? Cat = 2" & gt; Finansas & lt; / Button & gt; & Lt; Button value = "3" id = "3" href = "videos2-carrega.asp? Cat = 3" & gt; Promotions & lt; / Button & gt; & Lt; Button value = "4" id = "4" href = "videos2-carrega.asp? Cat = 4" & gt; Expectedism & lt; / Button & gt; Thank you for your attention.
$ (document) .ready (function () {$ ('div # filter-container Button '). Click (function () {var id_button = $ (this) .val (); $ ("#" + id_button + ""). AddClass ("cbp-filter-item-active"); $ ( This) .siblings (). RemoveClass ('cbp-filter-item-active'); // Added line}};});
Added line of code for the remaining button Demo:
In fact, very simple:
$ (document) .ready (function () {$ ('div # filter-container button '). Click (function () {$ (This) .addClass ("cbp-filter-item-active"); $ (this) .siblings (). RemoveClass (' cbp-f Ilter-item-active ');});});
You do not need an ID to choose $ $ (this) will be okay ...
< / Div>
Comments
Post a Comment