jQuery parent()

Posted by Happy on Stack Overflow See other posts from Stack Overflow or by Happy
Published on 2010-05-11T19:47:23Z Indexed on 2010/05/11 19:54 UTC
Read the original article Hit count: 167

Filed under:
|

jQuery snippet:

$(".sliders dt a").click(function(){
    $(this).parent().parent().parent().find(".triggers a").removeClass("active");
    return false
});

HTML:

<div class="triggers"><a href="#" class="active">Hide all</a></div>
<dl class="sliders">
    <dt><a href="#">text</a></dt>
    <dd>text</dd>
</dl>

Three .parent() is used, to catch .triggers block. Is there any way to merge them?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about parent