queryselectorall javascript images in list 1

queryselectorall javascript images in list

var elem = document.getElementsByClassName("flex-figure");

for (var i = 0; i <= elem.length; i++) {
    var imgTag = elem[i].getElementsByTagName('img')[0];
    var srcLink = imgTag.src;
    console.log(srcLink);
}

Here is what the above code is Doing:
1. We are getting all the elements with the class name "flex-figure"
2. We are looping through all the elements with the class name "flex-figure"
3. We are getting the first image tag from the element with the class name "flex-figure"
4. We are getting the source link of the image tag
5. We are printing the source link of the image tag

Similar Posts