Here is my html code:
<div class="container-fluid instructions">
<img src="chick2.png">
<img class="img1" src="dice6.png">
<img class="img2" src="dice6.png">
<img class="img3 threeChoices" src="dice6.png">
<img class="img4 fourChoices" src="dice6.png">
<img src="chick1.png">
</div>
<div class="dropdown">
<button class="btn btn-info dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
2
<span class="caret"></span>
</button>
<ul id="list" class="dropdown-menu dropdown-info" aria-labelledby="dropdownMenu1">
<li><a href="#">2</a></li>
<li><a href="#">3</a></li>
<li><a href="#">4</a></li>
</ul>
<input type="text" name="" value="" placeholder="Choice 1"> <br>
</div>
And here is my javascript:
let links = document.querySelectorAll('#list li')
links.forEach((el) => {
el.addEventListener('click', (event) => {
let numberOfChoices = event.target.innerText
document.getElementById('dropdownMenu1').innerHTML = `${numberOfChoices}<span class="caret"></span>`
console.log(numberOfChoices)
// Showing Correct Number of Boxes
if (numberOfChoices === 2) {
document.querySelectorAll(".img3").classList.add(".invisible");
}
})
})
and this is the css:
.invisible{display: none;}
If 2 is selected on the dropdown button, I want image with class img3 to be disappear. Why is it not working can someone help please thanks in advance