Solution 1 :

document.querySelectorAll() returns a node list, not a single img element, so you can not do:;

What you would have to do is iterate through that node list and apply desired styles to each element.

Problem :

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">


Css :

 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;


height: 160px;
width: 150px;


i try with query selector All It doesnt work :

var imges = document.querySelectorAll('.imgg');

I try with getElementsByTagName still doesnt work :

var imges = document.getElementsByTagName('img');;

i try with getElementsByClassName and the same issue

how to fix this ?


Comment posted by Lowkase

Pretty sure var images becomes an array that you have to step through to set the style on each image instance.

Comment posted by Dejan.S

this is not an answer