Reputation: 133
How would I get the attribute 'src' from the following tag:
<div class="entry"><img width="300" height="200" src="http://domain/myimg.jpg" alt="text" /></div>
Upvotes: 0
Views: 42
Reputation: 1215
I would recommend using an ID for the 'entry' element (or directly on the image element) instead of a class.
If that's not possible use this:
var x = document.querySelector('.entry img');
alert('src: ' + x.getAttribute('src'));
Upvotes: 2