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

  • SEARCH
  • Home
  • 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 8579661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:39:24+00:00 2026-06-11T20:39:24+00:00

I am currently learning the api of Jquery. I understand Jquery has a hover

  • 0

I am currently learning the api of Jquery. I understand Jquery has a hover function as reflected below:

hover( handlerIn(eventObject) , handlerOut(eventObject))

With the second handlerOut(eventObject), I can handle events like collapsing a menu tree when it is not hovered over.

I then looked at the api for the click function as reflected below:

.click( [eventData], handler(eventObject) )

Similar to what I want to achieve in my previous description, I have a menu tree. When a list item is clicked, it will dropdown to a submenu. My question is how do I collapse this submenu tree when I click out of the menu or click on other items?

lastly, I am using jquery-1.2.6.min.js to achieve this.

My jQuery:

 $("li.p1:has(ul)").click(function(event){
    if (this == event.target) {
    var current = this;
    $("#nav li:has(ul)").each(function() {
        if (this != current) $(this).children().slideUp(400);
    });
        $("ul:first", $(this)).slideToggle(400);
    }
    },function(){$(this).children().slideUp(400);});

My HTML:

    <div id="wrap">
    <ul id="nav">
    <li class="p1 down">Manage Subject
        <ul>
            <li><a href="#url">Add Subject</a></li>
            <li><a href="#url">Edit Subject</a></li>
            <li><a href="#url">Delete Subject</a></li>
            <li><a href="#url">Export Subject</a></li>
        </ul>
    </li>
    <li><a href="#url">Manual Crawling</a></li>
    <li><a href="#url">Crawl Interval</a></li>
    <li><a href="#url">Search Parameter</a></li>
    </ul>
    </div>
  • 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-06-11T20:39:25+00:00Added an answer on June 11, 2026 at 8:39 pm

    One way that I can think of is to create an event handler for the ‘body’ element.

    $('body').click(function(event){
       //Needs validation.
       if ($('li.p1:has(ul)') != event.target) {
            $("#nav li:has(ul)").each(function() {
                if (this != current) $(this).children().slideUp(400);
            });
        }
    });
    

    The aim is to add an event handler to the ‘body’ element and probe to see whether the intended element was clicked. If not, then slide it up. I think the same can be done in a better fashion.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently learning Hibernate and the Java Persistence API. I have an @Entity
I’m currently learning the Java Collections API and feel I have a good understanding
I've recently started learning about .net and the Windows API and I'm currently writting
I'm currently learning the HDF5 API and I'm trying to insert a set of
im currently learning jQuery and have ran into a problem. I am trying to
i´m currently learning Core Data. Core Data is great but i can not explain
I am currently learning ASP.NET MVC so please excuse my question if it has
I'm currently learning Windows programming through the Win32 API using Petzold's book as a
im currently learning python (in the very begining), so I still have some doubts
im currently learning stacks in java and have a quick question. what will the

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.