Getting the first image elements id within an unordered list using JQuery
Posted
by Roland
on Stack Overflow
See other posts from Stack Overflow
or by Roland
Published on 2010-05-12T18:50:22Z
Indexed on
2010/05/12
18:54 UTC
Read the original article
Hit count: 275
jQuery
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');
© Stack Overflow or respective owner