I wanted to have a javascript function to basically return an array of all the img src there is in a page, how do I do this?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can easily get an array containing all
imgelements viadocument.getElementsByTagName():Instead of
document.getElementsByTagName('img')you could also use thedocument.imagescollection.If you are using jQuery, you can also use
$('img')which gives you a jQuery object containing allimgelements.