How to get all the image sources on a particular Page using Javascript

前端 未结 5 1365
感动是毒
感动是毒 2021-02-08 03:26

I am using a simple script to find an image on a page and get its source.

function img_find() {
    var img_find2 = document.getElementsByTagName(\"img\")[0].sr         


        
5条回答
  •  梦如初夏
    2021-02-08 03:31

    I searched the whole web for a solution to this, maybe this will help if someone else searches the same.

    for(var i = 0; i< document.images.length; i++){
    document.images[i].style.border = "1px solid #E0FDA6";
    }
    

    Meaning, search all images that have style tag (border in this example) and set all borders to E0FDA6 (useful to reset single highlighted images), but I guess it can be used for everything with style tag.

    Rg, Anjanka

提交回复
热议问题