jquery selecting sibling node of the current node

Posted by priyank.mp on Stack Overflow See other posts from Stack Overflow or by priyank.mp
Published on 2010-05-13T00:45:38Z Indexed on 2010/05/13 0:54 UTC
Read the original article Hit count: 217

Filed under:
|

How do I select sibling node of the current node? Here is the snippet:

<div id="main">
    <a class="test" href="test.html">Hello</a>
    <div>Some text</div>
</div>

//script
$(".test").click(function() { $("this:parent > div").toggle(); });
or
$(".test").click(function() { $("this ~ div").toggle(); });

None of these works. I know I can access current object using $(this) but in this case I don't know how.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jquery-selectors