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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:15:40+00:00 2026-05-25T14:15:40+00:00

I have this menu: <ul id=nav> <li class=level0>Item 1</li> <li class=level0 parent> <a><span>Click Me!</span></a>

  • 0

I have this menu:

<ul id="nav">
<li class="level0">Item 1</li>
<li class="level0 parent">
    <a><span>Click Me!</span></a>
    <div class="submenu">
        <ul>
            <li>Subitem 1</li>
            <li>Subitem 2</li>
        </ul>
    </div>
</li>
</ul>

I want the submenu to be hidden when the page is loaded. When the user clicks the parent item, the submenu should appear.

When I use inline CSS like this, everything works fine.

<div class="submenu" style="display:none;">

See this demo: http://jsfiddle.net/zJk6P/ (Click on “Click me” in the bottom right to run the demo.)

When I use external CSS like this, the submenu doesn’t appear anymore.

#nav div.submenu{
display: none;
}

See this demo: http://jsfiddle.net/5tNqc/4/

Why is there any difference and how can I get the sliding effect to work with external CSS?

  • 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-25T14:15:41+00:00Added an answer on May 25, 2026 at 2:15 pm

    The reason my code didn’t work was that Javascript doesn’t have access to external CSS style declarations. Only inline styles are accessible trough element.style.

    Effect.toggle(element, 'slide'); tries to slide the element down when the element is not displayed, and up when the element is displayed. So when the element is hidden by an external style sheet, Effect.toggle will try to slide the element up, because it simply doesn’t “know” the element is already hidden.

    The solution is to work with class names. My final solution checks whether the element has a certain class name. When the class name is present, the element is not clicked yet, so the element is slided down and the class name is removed. All next clicks, the element is toggled.

    I built and uploaded a small demonstration here: http://i.amniels.com/ext/stackexchange/2011-09/index.html

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

Sidebar

Related Questions

I have the following HTML: <div class=menu> <a class=main-nav-item href=home>home</a> <a class=main-nav-item-current href=business>business</a> <a
Assuming I have this HTML structure: <ul class='menu'> <li> <div></div> <div> <div></div> <div> <a
i have this html menu: <ul id='main'> <li class='active current' id='lighty'> <a href='/'>Lighty</a> <ul>
I have this html structure <div class=top_menu> <ul> <li class=left><a href= class=family-filter>asdas</a></li> <li class=welcome>Welcome
I have anchor tags like this <div id=menu_container> <ul id=nav-bar> <li><a href=Default.aspx runat=server id=menu_item_default>Home</a></li>
I want to apply this attribute: onclick=​expandMenu(this.parentNode)​ to every li with the class=parent So
I have a nested ul menu structure that starts off like this: <div id=left>
I have this CSS dropdown menu. I want the homepage to start on the
I have the following simple 3 level menu structure: <nav class=main-nav class=list> <ul> <li
I have this menu structure that is used to navigate through content slider panels.

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.