jquery toggling more than one div

Posted by Crays on Stack Overflow See other posts from Stack Overflow or by Crays
Published on 2010-05-09T03:42:29Z Indexed on 2010/05/09 3:48 UTC
Read the original article Hit count: 204

Filed under:

Hi guys, i'm trying to make toggling div with only 1 javascript.

I tried this, the first div does what it was meant to do but the second doesn't.

Have a look.

<body>
    <div>
    <div>He
        <div>You
            <div id="Me"><a id="me">Me</a></div>
        </div>
    </div>
    <div id="This">We
    </div>
    </div>
    <div>

    <div>1
        <div>2
            <div id="Me"><a id="me">3</a></div>
        </div>
    </div>
    <div id="This">4
    </div>
    </div>
<script>
    $("#me").click(function () {
      $(this).parent().parent().parent().siblings("#This").slideToggle("slow");
    });
</script>
</body>

when i click me, we disappear, alright. But when i click 3, 4 doesn't disappear.

© Stack Overflow or respective owner

Related posts about jQuery