Js method to find the address of all images in an element

  • 2020-03-30 01:24:53
  • OfStack

 
function findImg() { 
var charImg = document.all("chartImg").getElementsByTagName("img"); 
var imgURLs = ""; 
for (var i = 0; i < charImg.length; i++) { 
var imgPath = getImgPath(charImg[i].src); 
var imgNames=getImgNames(imgPath); 
if (imgNames!= "vt2.png") { 
imgURLs += imgNames; //If use the document. GetElementsByTagName (" img ") [I]. SRC; Every time you take an image address, you will find all the images, so the efficiency is low, or better stored in imgs!
} 
} 
alert( imgURLs); 

} 


Related articles: