Trying to target all images using JavaScript, here is the code:
HTML :
<div class="container">
<img src="Coca.jpg" class="imgg">
<img src="Water.jpg" class="imgg">
<img src="Tree.jpg" class="imgg">
<img src="Alien.jpg" class="imgg">
</div>
CSS :
.container{
margin: 0;
padding: 0;
position: absolute;
height: 480px;
width: 600px;
top: 23%;
left: 20%;
box-sizing: border-box;
background-color: red;
display: flex;
flex-wrap: wrap;
align-content: flex-start;
}
img{
height: 160px;
width: 150px;
}
Tried using querySelectorAll but it didn't work :
var imges = document.querySelectorAll('.imgg')
imges.style.opacity=0;
Also tried with getElementsByTagName and getElementsByClassName with no success :
var imges = document.getElementsByTagName('img');
imges.style.opacity=0;
How can this issue be fixed ?