jQuery multiple parent() calls

浪子不回头ぞ 提交于 2019-11-28 11:27:46

You can use a class (or any other selectable attribute) and .closest() to claim to the parent you want, like this:

<div class="container">
    <div>
        <a href="">$(this) object</a>
    </div>

    <div>
        <a href="">object to fade in</a>
    </div>
</div>

And for the script:

$(this).closest(".container").find(".license_tooltip").stop(true, true).fadeIn(200);

You could use the .parents( [ selector ] ) here is a link

It will traverse more than one parent up.

use parents()

$(this)
    .parents('selector for the parent you need to look in')
    .find(".license_tooltip")
    .stop(true, true)
    .fadeIn(200);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!