nearest ancestor node in jQuery

后端 未结 4 1741
情歌与酒
情歌与酒 2021-01-07 23:53

In my javascript experience, I found that is a very common task \"searching the nearest ancestor of an element with some condition (tag name, class,...)\". Can the parents(

4条回答
  •  庸人自扰
    2021-01-08 00:36

    closest() starts at current element, if the parent you are looking for has the same tag as current (eg. both are divs), use parent().closest()

提交回复
热议问题