jQuery ancestors using jQuery objects

前端 未结 7 1747
北荒
北荒 2021-01-02 18:33

I\'d like to check ancestry using two jQuery objects. They don\'t have IDs, and are only going to be available as jQuery objects (or DOM nodes if you called get()

7条回答
  •  孤城傲影
    2021-01-02 18:59

    Checking for (this).parents().index(someDiv) >= 0, as @Gareth suggests, will work just fine.

    However, using the jQuery ancestry plugin is way faster / more efficient.

提交回复
热议问题