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