I'm building a character creator using just HTML, CSS and Vanilla JS. I have 3 options for each page that all are buttons and their initial opacity is set to 0.5 but when you hover on the button it will increase the opacity to 1. The intended outcome would be that the user would hover over the selections to increase the opacity and when they click on their choice, it will keep that opacity as they have made their selection.
Any ideas here on where I went wrong and what else could possibly work? I've searched everywhere but I am not sure if this is possible in Vanilla JS with the code I have.
rogueButton.addEventListener('click', () => {
rogueButton.classList.remove('hoverEffect')
rogueButton.classList.add('classSelected')
characterSelections[0] = 'Rogue';
characterSelections[8] = 'Dexterity';
document.getElementById("primaryAbilityCS").innerHTML = characterSelections[8];
raceContinue.classList.add('continueButtonSelected');
})
.hoverEffect:hover {
opacity: 1;
}
.characterChoices {
opacity: 50%;
transition: 0.3s;
}
.characterSelected {
opacity: 1;
}
<div class="characterChoices hoverEffect" id="rogue">
<button class="flex optionBackground classChoice" id="rogueButton" type="button">
<div class="classselection">
<div class="sectioninfowrapper">
<h3>ROGUE</h3>
<img src="img/infoicon1.png" class="infoiconwrapper2" id="roguePopup">
<span class="hidden popupStyling" id="rogueInfoPopup">Rogues are real sneaky.</span>
</div>
<img src="img/banner.png" width="100%">
<div class="sectioninfowrapper">
<p>Primary Ability</p>
<img src="img/infoicon1.png" class="infoiconwrapper1" id="roguePrimaryAbilityPopup">
<span class="hidden popupStyling" id="roguePrimaryAbilityInfoPopup">You're naturally light on your feet.</span>
</div>
<p class="classinfo">Dexterity</p>
</div>
<img src="img/rogue.png" alt="rogue">
</button>
</div>