document.querySelectorAll() returns a node list, not a single img element, so you can not do:
imges.style.opacity=0;
What you would have to do is iterate through that node list and apply desired styles to each element.
document.querySelectorAll() returns a node list, not a single img element, so you can not do:
imges.style.opacity=0;
What you would have to do is iterate through that node list and apply desired styles to each element.
Im trying to select all images in javascript var hers 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;
}
i try with query selector All It doesnt work :
var imges = document.querySelectorAll('.imgg')
imges.style.opacity=0;
I try with getElementsByTagName still doesnt work :
var imges = document.getElementsByTagName('img');
imges.style.opacity=0;
i try with getElementsByClassName and the same issue
how to fix this ?
Pretty sure var images becomes an array that you have to step through to set the style on each image instance.
this is not an answer