jQuery | Click child, hides parent

Posted by Jamie on Stack Overflow See other posts from Stack Overflow or by Jamie
Published on 2010-05-08T15:00:09Z Indexed on 2010/05/08 15:08 UTC
Read the original article Hit count: 325

Filed under:
|
|
|

Hey, I have a list of using ul and li:

<span class="important">Show/Hide</span>

<div id="important" class="hidden">
    <ul class="sub">
     <li>
            Value one
        </li>
        <li class="child">
            <img src="../img/close.png" />
        </li>
    </ul>
</div>

$(".important").click(function () {
  $("#important").slideToggle("fast");
});

When the child (class="child") is clicked on, it should slide up the div (id="important"), however, there are other lists that have different IDs, I want the div to slide up when the child is clicked

I did this:

$(".child").click(function () {
  $(".child < div").slideUp("fast");
});

I have no idea how to make it work, I've done other combinations, can't seem to do it.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about show-hide