How to select last child element in jQuery?
Just the last child, not its descendants.
You can also do this:
<ul id="example"> <li>First</li> <li>Second</li> <li>Third</li> <li>Fourth</li> </ul> // possibility 1 $('#example li:last').val(); // possibility 2 $('#example').children().last() // possibility 3 $('#example li:last-child').val();
:last
.children().last()
:last-child
1.4m articles
1.4m replys
5 comments
57.0k users