jQuery last() methodAs its name implies, the last() method returns the last element of the selected elements. It is an inbuilt method in jQuery. If we need to get the first element, we can use the first() method. SyntaxThis method doesn't accept any argument. The selector in the above syntax is mandatory to be specified. Let's see some of the illustrations to understand how to use the last() method. Example1In this example, we are using the last() method to get the last span element from the set of elements. Test it NowOutput After the execution of the above code, the output will be - After clicking the given button, the output will be - Example2In this example, we are using the last() method to get the last paragraph element from the set of elements. We are using the p as the selector, so the method will return the last paragraph element. Test it NowOutput After the execution of the above code, the output will be - After clicking the given button, the output will be - Next TopicjQuery isNumeric() method |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India