JQuery, find parent

后端 未结 7 1615
日久生厌
日久生厌 2021-01-31 02:15
$(\'#thisid\').parent(\'li\');
7条回答
  •  说谎
    说谎 (楼主)
    2021-01-31 03:09

    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.

提交回复
热议问题