I’m trying to collapse every element except the last one with this line of Jquery code:
$(".message_list .message_body:lt(:last-child)").hide();
Nothing collapses with this line. I have tried:
':last child'
:last-child
last()
:last
':last'
but nothing gives me the last element. How can I select every element less than the last element? What goes in the lt()?
Try this:
Or depending on how your HTML is structured, you may need
:last.