Late to the party again but for what it's worth it is possible using jQuery to be a little more succinct. In my case I needed to find the
parent tag for a
tag contained in the child
. jQuery has the :has
selector so it's possible to identify a parent by the children it contains (updated per @Afrowave's comment ref: https://api.jquery.com/has-selector/):
$("ul").has("#someId")
will select the ul
element that has a child element with id someId. Or to answer the original question, something like the following should do the trick (untested):
$("li").has(".active")