jQuery ancestors using jQuery objects

前端 未结 7 1749
北荒
北荒 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 19:05

    Try this:

    var someDiv = $('#div');
    
    $('a').click(function() {
        if ($.inArray($(this).parents().get(), someDiv.get(0)) {
            alert('boo');
        }
    }
    
    0 讨论(0)
提交回复
热议问题