- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
jQuery :last-child Selector
The :last-child selector in jQuery is used to select all elements that are the last child of their parent.
Syntax
The syntax is as follows −
$(":last-child")
Example
Let us now see an example to implement the jQuery :last-child Selector −
<!DOCTYPE html> <html> <head> <style> .one { color: white; background-color: green; font-size: 16px; border: 2px blue solid; } </style> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("p:last-child").addClass("one"); }); </script> </head> <body> <h1>Examination Details</h1> <p>Date: 25th October 2019</p> <p>Timings: 10AM TO 1PM</p> <p>All the best for exams!</p> </body> </html>
Output
This will produce the following output −
- Related Articles
- jQuery :nth-last-child() Selector
- jQuery :first-child Selector
- jQuery :nth-child() Selector
- jQuery :only-child Selector
- jQuery parent > child Selector
- jQuery :last Selector
- Role of CSS :last-child Selector
- jQuery :last-of-type Selector
- Last-child and last-of-type selector in SASS
- jQuery :nth-last-of-type() Selector
- Role of CSS :nth-last-child(n) Selector
- CSS Child Selector
- How to insert element as a last child using jQuery?
- jQuery :button Selector
- jQuery :checkbox Selector

Advertisements