jQuery:Selector :first

Overview

Get the first element.

Demo

Description:

Gets the first element of the match.

HTML code:
<ul>
    <li>list item 1</li>
    <li>list item 2</li>
    <li>list item 3</li>
    <li>list item 4</li>
    <li>list item 5</li>
</ul>
jQuery code:
$('li:first');
Result:
[ <li>list item 1</li> ]

Leave a Reply

Your email address will not be published. Required fields are marked *