JavaScript:
const buttons = document.getElementsByClassName("togglebtn");
for (let i = 0; i < buttons.length; i++) {
buttons[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 facing an issue where I can change the color of text but not the background color. My goal is to modify the color when a button is clicked. The :after in CSS works, but changing the color does not. Can someone please provide suggestions on what I may be doing wrong?