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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:48:36+00:00 2026-05-27T14:48:36+00:00

I am using a Jquery Toggle sidebar menu, so there is a down arrow

  • 0

I am using a Jquery Toggle sidebar menu, so there is a down arrow in the menu to push the menu down to show sub-menu(s) every time you click on it. My problem is when there is no child menu/sub-menu, the down arrow is still showing up, and when you click on it, it eats the same level menu below. I am using the menu in Silverstripe. How can I make the arrow shows only when there is a child menu/submenu?

/———————————————–Here is my toggle menu js————————————————–/

$(document).ready(function() {

$('.second_level').hide();

$("div.menu > h3").css("background", "url(themes/tutorial/images/menuarrowdown.gif) no-repeat right");

$('div.menu > h3').click(function() {

$(this).next().slideToggle('fast', function() {

//set arrow depending on whether menu is shown or hidden
if ($(this).is(':hidden')) {

$(this).prev().css("background", "url(themes/tutorial/images/menuarrowdown.gif) no-repeat right");
} else {
$(this).prev().css("background", "url(themes/tutorial/images/menuarrowup.gif) no-repeat right");
}
return false;
});
});
});

/————————————Here is my html code———————————————-/

<div id="productmenu"> <!-- productmenu starts -->
<div class="menu">                      
  <h3><a href="#">Category 1</a></h3>
    <ul class="second_level">
      <li><a href="page.html">Option 1</a></li>
      <li><a href="page.html">Option 2</a></li>
   </ul>
</div> <!-- /menu -->

<div class="menu">

   <h3><a href="#">Category 2</a></h3>

</div> <!-- /menu -->

<div class="menu">
  <h3><a href="#">Category 3</a></h3>
     <ul class="second_level">
      <li><a href="page.html">Option 1</a></li>
       <li><a href="page.html">Option 2</a></li>
      <li><a href="page.html">Option 3</a></li>
    </ul>
</div> <!-- /menu -->
</div><!-- /productmenu -->

/————————————Here is my page.ss———————————————-/

  <% control Menu(2) %>

     <h3><a href="$Link" title="Go to the &quot;{$Title}&quot; page">$MenuTitle</a></h3>

        <% if Children %>   <ul class="second_level">
              <% control Children %>
               <li class="$LinkingMode"><a href="$Link" title="Go to the &quot;{$Title}&quot; page">$MenuTitle</a></li>
              <% end_control %></ul>

        <% end_if %>
  <% end_control %>

Your help is appreciated. Please see example pic below.

Thanks
Sam

enter image description here

Edit: To fix the eating up menu issue, just move <% control Menu(2) %> above and <% end_control %> below the finish div of menu. Js solution is to use Matt’s new Js. Thanks Matt, Iank and Milo! I appreciate your help!

  • 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-27T14:48:37+00:00Added an answer on May 27, 2026 at 2:48 pm

    You never tell your system to not print the down arrow if no child exists. It adds the arrow to every H3 that exists in them menu and never considers if it has children or not. So we need to check each menu item to see if it has children. The following should do that:

    $("div.menu").each(function(){
    
      if($(this).children().length > 1) // See if the H3 is the only child
      {
          $(this).children("H3").css("background", "url(themes/tutorial/images/menuarrowdown.gif) no-repeat right");
      }
    
    });
    

    Presently I’m on lunch break and do not have time to fully test this. I have no verified this will work.

    EDIT: Modified code after Sam put in his pure HTML.

    EDIT2: After Sam supplied a fiddle, I forked it and made corrections.Fiddle: http://jsfiddle.net/GvGoldmedal/Wp2em/

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

Sidebar

Related Questions

I'm using simple jQuery toggle method: $('fieldset').click(function () { $('fieldset>ul').toggle(slow); }); Is there any
I am using the toggle() with jQuery and I have a sidebar on my
i'm using jquery toggle to show/hide a div on different links. It shows/hides them
I am using jQuery's toggle() to show/hide table rows. It works fine in FireFox
I'm using the jQuery toggle effect hooked to the click() event of 1 table
I want to toggle objects using JQuery. I can just only show/hide objects and
I've made a drop down navigation using Jquery and css. When you click a
I have my wordpress post content hidden using a jquery toggle effect. The problem
I'm using a jQuery toggle effect from Sohtanaka in order to 'show' and 'hide'
Hi again :) I'm using jQuery script to show/hide some content: <script type=text/javascript> $('.toggleButton').click(function()

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.