You may actually want to use $("#thisid").closest('li')
. This traverses up the DOM tree from the selected node and returns the first matching ancestor whereas the .parents()
travels from the parent node and returns all ancestor nodes matching that filter. See here for more information.