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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T02:05:49+00:00 2026-06-19T02:05:49+00:00

I have a custom accordion menu with [+] link next to each expandable UL

  • 0

I have a custom accordion menu with [+] link next to each expandable UL (toggle_action) to expand its child (div_toggle). For the active

  • (the page being viewed) I’m trying to traverse up the DOM and change any plus.gif images into minus.gif next to its parent
  • s since they are already expanded. I’ve searched for most of the day and going crazy. Below is my latest attempt that I thought was surely going to work. I don’t get any errors – it just doesn’t work.

    Here’s my HTML:

        <ul class="topnav">
          <li><h3 class="toggle_action"><img class="img-swap" src="/images/plus.gif"/>Governance</h3>
            <ul class="div_toggle">
              <li><h3><img src="/images/spacer.gif"/><a href="/governance">Governance</a></h3></li>
              <li><h3 class="toggle_action"><img class="img-swap" src="/images/plus.gif"/>Board of Directors</h3>
                <ul class="div_toggle">
                  <li><h3><img src="/images/spacer.gif"/><a href="/governance/bod" class="active">Board of Directors</a></h3></li>    
                  <li><h3><img src="/images/spacer.gif"/><a href="/governance/bod/min">Minutes</a></h3></li>
                </ul>
              </li>
              <li><img src="/images/spacer.gif"/><a href="/governance/com">Committees</a></h3></li>
            </ul>
          </li>
          <li><h3 class="toggle_action"><img class="img-swap" src="/images/plus.gif"/>About</h3>      
            <ul class="div_toggle">
              <li><h3><img src="/images/spacer.gif"/><a href="/about">About Us</a></h3></li>
              <li><h3><img src="/images/spacer.gif"/><a href="/about/contact">Contact</a></h3></li>
            </ul>
          </li>
       </ul>
    

    and the jQuery:

    $('.topnav a.active').parents().attr('src').replace('plus.gif','minus.gif');
    

    What am I doing wrong?? Thanks in advance!

    • 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-19T02:05:50+00:00Added an answer on June 19, 2026 at 2:05 am

      The way you have your html nested, it will never grab the <img> tag because it is not considered a parent of the active class <img> tag.

      You should consider changing the way your HTML is being outputted most definitely.

      But here’s a solution to your problem in the current way that you html is being nested.

      $(".active").parents(".div_toggle").prev("h3:first").children(":first").addClass("plus");
      
      $('h3.toggle_action img').each(function(){
          if ($(this).attr('src') && $(this).hasClass('plus') && $(this).attr('src').indexOf('plus.gif') > 0)
          {
              var imgSrc = $(this).attr('src').replace('plus.gif','minus.gif');
              $(this).attr('src', imgSrc);
          }
      });
      

      Ok, what this does, is that it grabs the "active" parents <h3> child <img> and adds a class to it called "plus" and uses this class when looping through the <h3 class="toggle_action"><img> tags, making sure to grab the img tag with plus as a class, and changes the other ones to the minus.gif image.

      Hope this helps you. If so, mark it as your answer.

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

    Sidebar

    Related Questions

    I have created custom master page with custom elements included according to this link:
    I have a custom accordion script that I'm trying to adapt for another site.
    I have a custom accordion script - http://jsfiddle.net/nJpNb/2/ What I want to be able
    Hi I have a accordion menu in a wordpress site. The standard menu that
    I have an accordion menu that is working excellent in chrome, IE8, firefox, however,
    I'm trying to create a custom accordion using jquery, have read through quite a
    im using a joomla 1.6.4 install and have a custom css/javascript drop-down menu in
    I'm having trouble explaining this but here it goes: I have a custom accordion
    **I am developing mobile web with Custom select menu containing menu Accordion using Vertical
    I am trying to create a custom accordion for my page to that display

    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.