JavaScript:
var acc = document.getElementsByClassName("togglebtn"),
i;
for (i = 0; i < acc.length; i++) {
acc[i].onclick = function () {
this.classList.toggle("active");
}
}
html:
<md-button class="md-fab togglebtn"></md-button>
css:
button.togglebtn:after {
background-color: white;
width: auto;
font-weight: bold;
margin-left: 5px;
border: none;
content:'';
}
button.togglebtn.active:after {
width: auto;
background-color: green;
content:'close';
font-size: 10px;
}
I am only able to change the color of the text but not the background color. I am trying to change the color when someone click on button. The :after is working in css but changing color is not working. Can someone suggest me, what I am doing wrong please