Getting the first image elements id within an unordered list using JQuery
- by Roland
I'm trying to get the id of the first element of an unordered list using JQuery.
Here's the list
<ul class="list">
<li><img id="1" src="image1.jpg" name="image1" /></li>
<li><img id="2" src="image2.jpg" name="image2" /></li>
<li><img id="3" src="image3.jpg" name="image3" /></li>
<li><img id="4" src="image4.jpg" name="image4" /></li>
<li><img id="5" src="image5.jpg" name="image5" /></li>
</ul>
JQuery
var id = $('.list li img'):first.attr('id');