Similar to jQuery .closest() but traversing descendants?

后端 未结 16 713
情书的邮戳
情书的邮戳 2020-12-07 15:13

Is there a function similar to jQuery .closest() but for traversing descendants and returning only closest ones?

I know that there is

16条回答
  •  無奈伤痛
    2020-12-07 15:59

    I would use the following to include the target itself if it matches the selector:

        var jTarget = $("#doo");
        var sel = '.pou';
        var jDom = jTarget.find(sel).addBack(sel).first();
    

    Markup:

    poo
    foo
    pooo

提交回复
热议问题