What would be the best way to get the IMG SRC to an array such as:
var images = [ ‘img1.png’, ‘img2.png’, img3.png’ ];
<div class="cc">
<img class='content-image' src="./img1.png" alt="">
<img class='content-image' src="./img2.png" alt="">
<img class='content-image' src="./img3.png" alt="">
<img class='content-image' src="./img4.png" alt="">
<img class='content-image' src="./img5.png" alt="">
</div>
Have tried this:
var images = []; const interactImg2 = document.querySelector('.cc'); [...interactImg2.querySelectorAll('img[src]')].forEach(img => images.push(new Image('img[src]')));
Unable to get the SRC but the item shows as ( Image1, Image2, Image3 )
New contributor
Lena is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.