Menu
Newbedev LogoNEWBEDEV Python Javascript Linux Cheat sheet
Newbedev LogoNEWBEDEV
  • Python 1
  • Javascript
  • Linux
  • Cheat sheet
  • Contact

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

You indeed told the code to do so. Don't do that. Just tell it to loop over all images and push the src of each in an array and return the array with all srcs instead.

function img_find() {
    var imgs = document.getElementsByTagName("img");
    var imgSrcs = [];

    for (var i = 0; i < imgs.length; i++) {
        imgSrcs.push(imgs[i].src);
    }

    return imgSrcs;
}

Tags:

Javascript

Image

Related

How to start a process in its own process group? What is the usefulness of NMTOKEN and NMTOKENS types? Casting to int in awk Customize error message with simple_form Get sum of MySQL column in PHP SQL Server: Maximum character length of object names How to select jQuery drop down val() AND trigger the event? getContext is not a function Changing the background color of a selected JToggleButton Multiple item combo box with headers? C++ priority_queue with lambda comparator error Tomcat: how to access (session) Manager from servlet

Recent Posts

Pandas how to find column contains a certain value Recommended way to install multiple Python versions on Ubuntu 20.04 Build super fast web scraper with Python x100 than BeautifulSoup How to convert a SQL query result to a Pandas DataFrame in Python How to write a Pandas DataFrame to a .csv file in Python
© 2021 newbedevPrivacy Policy