Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 769617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:21:57+00:00 2026-05-14T18:21:57+00:00

Hey, I have a list of using ul and li: <span class=important>Show/Hide</span> <div id=important

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T18:21:57+00:00Added an answer on May 14, 2026 at 6:21 pm

    You can do it using .closest(), like this

    $(".child").click(function() {
      $(this).closest("div").slideUp();
    });
    

    This goes from the .child you clicked on up the the neatest <div> ancestor and slides it up. If you may have other divs between the child and parent, then I suggest giving the <div> you do want closed a class, and changing the closest call to look for that specific <div>, like this:

    $(".child").click(function() {
      $(this).closest("div.classToClose").slideUp();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys, I have a UL like so: <ul id=list> <li class=something> <div class=btns
Hey i have this div that shows as a popup: <div class=popup> </div> Then
hey guys, I have a standard nav bar with an unordered list and using
hey there i am having problem i have List<List<memoryCard>> that i want to show
Hey, Lets say we have a query which generates list of city names as
Hey I have a problem comparing the value of a CGPoint (struct with two
Hey we have a library class (lib/Mixpanel) that calls delayed job as follows: class
Hey, I right now have a list of a struct that I made, I
Python: How to remove all duplicate items from a list Hey guys I have
hey guys, say I have Entities and mappings like this: public class Episode {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.