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 7508055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:36:39+00:00 2026-05-29T22:36:39+00:00

I have a nav which on a click i expand it, but if it’s

  • 0

I have a nav which on a click i expand it, but if it’s already expanded and we click on the item again it shouldn’t do anything (return). I have this code but it is not working properly, currently if I click on the item it expands it but if i click again it closes the nav and if i click once again it expands it but it behaves funny. I basically only need to be able to click and open and do nothing if already opened as I will have a close button anyway.
p.s. “item” is a var i defined before in the code.

var item = $(".nav a");
<div class="nav">
    <a href="#">Trigger</a>
    <div class="wrapSubContent">
         <div class="wrapNavtoShowHide">
            ..content..
         </div>
     </div>
</div>

item.click(function(e) {
    e.preventDefault();
    $(".wrapSubContent").slideToggle("slow", "linear", function(){
        $(".wrapNavtoShowHide").slideToggle("slow", "linear");
    });
});

Anyone?

  • 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-29T22:36:39+00:00Added an answer on May 29, 2026 at 10:36 pm

    You should check if the div is hidden or not and then use slideDown.

    var item = $(".nav a");
    $(".wrapNavtoShowHide").hide();
    item.click(function(e) {
        e.preventDefault();
        if ($(".wrapNavtoShowHide").is(":hidden")) {
            $(".wrapNavtoShowHide").slideDown("slow", "linear");
        }
    });
    

    Take a look at the jsfiddle example of this in action.

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

Sidebar

Related Questions

I have this function in Jquery which basically says when you click on the
I have nav code like this in my HTML file: <div id="center_links"> <ul> <li><a
I have the following Nav: <li id=categories> <ul> <li class=cat-item cat-item-8 current-cat><a href=#>Link</a> <ul>
I have a basic website nav layout that looks like this: <li class=folder parent_folder>
I have custom javascript code for tabs which works fine, but Im trying to
I have this fancybox plugin wich is great, but I don't think there is
I have a TableView, when you click add + button in nav bar, it
I have this jquery: $('.tbl-link').click(function(){ $('.tbl-content').animate({ opacity: 'show', //height: '+=300px', marginTop: '330px' }, 1200).css({
I have the following code, I have implemented something like this so far, but
I have the following jQuery statement which works fine but I was wondering if

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.