So, on my website I have a pop-up modal that contains a form. The form has 5 divs that contain a picture and a description. I found the following JS code on w3schools that enables me to select a div and give it the styling I want. However, when I first open the modal, one div is selected. But I don't want any to be selected. I am not sure how to modify this code to make it so no divs are seleced initially.
// When user clicks an div, add background
var divs = document.getElementsByClassName("mood-state");
for (var i = 0; i < divs.length; i++) {
divs[i].addEventListener("click", function () {
var current = document.getElementsByClassName("active");
current[0].className = current[0].className.replace(" active", "");
this.className += " active";
});
}
Here is some of the div in the modal
<div class="mood-state">
<img src="neutral.svg" alt="" />
<p>Neutral</p>
</div>
<div class="mood-state">
<img src="smile.svg" alt="" />
<p>Pleasant</p>
</div>
<div class="mood-state active">
<img src="grin.svg" alt="" />
<p>Very Pleasant</p>
</div