before I start, I found this topic : Pressed <button> CSS which give half of the answer I'm looking for.
I have a button in a link and I would like it to keep his style after it gets pressed. ALSO, I would like to see it back to his normal style (before it get pressed) when I click somewhere else on the page.
Here is my code :
jQuery('.btnpublish').click(function(){
jQuery(this).toggleClass('active');
});
.btnpublish{
background-color: #7f8c8d;
border: 1px solid #7f8c8d;
font-weight: bold;
}
.btnpublish:hover{
background-color: #3498db;
border: 1px solid #3498db;
}
.btnpublish:active{
background-color: #3498db;
border: 1px solid #3498db;
}
.btnpublish.active{
background-color: #3498db;
border: 1px solid #3498db;
}
<ul class="" role="tablist">
<li class="active listlayer6publish"><a class="btn btn-dark btnpublish" href="#vtab1" role="tab" data-toggle="tab"> Sports</a></li>
<li class="listlayer6publish"><a class="btn btn-dark " href="#vtab2" role="tab" data-toggle="tab"> Santé</a></li>
</ul>
For now, when I press on the button "Sports", it keeps the active style before I press again on the button. The only problem is that i want to change it when I press anywhere else on the page.