Anthony James
Anthony James

Reputation: 252

Grabbing first child <span> from the parent element using jQuery

What jQuery function would I use to grab the closest to the top of a div <span> and also the very last in the list as well?

Upvotes: 0

Views: 1943

Answers (1)

RobertPitt
RobertPitt

Reputation: 57278

The HTML

<div id="spans">
    <span></span>
    <span></span>
    <span></span>
    <span></span>
    <span></span>
</div>

the jQuery:

$('#spans span:first,#spans span:last');

Your question requires more explanation but this is a punt at what your looking for.

Upvotes: 7

Related Questions