I’m trying to make buttons in a sidebar that act like radio buttons. I’ve applied an event listener to each one after having put the buttons in an array. I’m not sure how to make it so that only one can be in the pressed state (and stays there). Also, would anyone be able to tell me how I can change the CSS style for the pressed button?
Thanks
`radioButtons = Array.from(document.getElementsByClassName(“radioBtn1”));
textMsg = document.getElementById(“titleMsg”);
radioButtons.forEach(button => {
button.addEventListener(“click”, button => {
currentScreen = button.target.name;
textMsg.innerHTML = button.target.name;
console.log(button.target.name);
});
});
`