I'm trying to get the URL of a certain image out of the given HTML code
<div class="image_div_name">
<img src="http://www.thisistheimage.com" alt="">
</div>
So this is my current code that should solve it:
var picture = document.getElementsByClassName("image_div_name");
var src = picture[0];
If I now print picture via console.log, I get the correct div:
<div class="image_div_name">
<img src="http://www.thisistheimage.com" alt="">
</div>
However, if I want to access the src, it doesnt seem to work:
var src = picture[0].src;
console.log(src);
Gives back:
undedfined
If I try:
console.log(picture[0].innerHTML)
it gets better and I receive:
<img src="http://www.thisistheimage.com" alt="">
However I'm looking for way to merely get the URL itself, as in:
http://www.thisistheimage.com
Can you help? What am I doing wrong?