{"name":"first","type":"method","title":".first()","deprecated":null,"removed":null,"desc":"Reduce the set of matched elements to the first in the set.","categories":["traversing/filtering","version/1.4"],"entries":[{"return":"jQuery","signatures":{"added":"1.4"},"examples":{"desc":"Highlight the first span in a paragraph.","css":"\n .highlight{\n background-color: yellow\n }\n","code":"\n$( \"p span\" ).first().addClass( \"highlight\" );\n","html":"\n
\n Look:\n This is some text in a paragraph.\n This is a note about it.\n
\n"},"longdesc":"\nGiven a jQuery object that represents a set of DOM elements, the .first() method constructs a new jQuery object from the first element in that set.
Consider a page with a simple list on it:
\n\n<ul>\n <li>list item 1</li>\n <li>list item 2</li>\n <li>list item 3</li>\n <li>list item 4</li>\n <li>list item 5</li>\n</ul>\n \n We can apply this method to the set of list items:
\n\n$( \"li\" ).first().css( \"background-color\", \"red\" );\n \n The result of this call is a red background for the first item.
\n "}]}