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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:36:15+00:00 2026-05-15T08:36:15+00:00

I have a simple piece of jquery i am using to toggle the visibility

  • 0

I have a simple piece of jquery i am using to toggle the visibility of a div (below). What I’d like to add is some text and a little plus sign image that changes to different text and a minus sign image after the div is expanded. Here is my code:

jQuery

$(document).ready(function(){
  $(".toggle").click(function(){
  $(".hidden").slideToggle("slow");
  });
});

html

// this will be changed to  Hide Panel <img src="minusSign.gif"> 
// and doesn't have to live in a <p>
<p class="toggle">Show Panel <img src="plusSign.gif"></p>
<div class="hidden">
Blah Blah Blah
</div>

css

.hidden {display:none;}

Any advice on how to achieve what I’m looking for? Currently, the div toggles just fine, but the trigger text/image is static.

Thanks!

  • 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-15T08:36:16+00:00Added an answer on May 15, 2026 at 8:36 am

    I can’t help but noticed you need something like this…

    $(".toggle").click(function(){
        $(".hidden").slideToggle("slow");
        $(this).html(function(i,html) {
            if (html.indexOf('Show') != -1 ){
               html = html.replace('Show','Hide');
            } else {
               html = html.replace('Hide','Show');
            }
            return html;
        }).find('img').attr('src',function(i,src){
            return (src.indexOf('plusSign.gif') != -1)? 'minusSign.gif' : 'plusSign.gif';
        });
    });
    

    and I baked you a demo

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

Sidebar

Related Questions

I have this simple piece of HTML code: <div> <input type=file name=english-file /> </div>
I have this simple piece of code in jQuery $(document).ready(function() { $('#switcher').click(function(event) { if
I have what I thought was a simple piece of jquery, but it's turning
I am currently developing a mobile site using jQuery mobile. I have one simple
I have a simple piece of jQuery which injects a new row (...) which
I have this simple piece of code in c++: int main(void) { string text
I have a simple HTML page that looks like this: ...<div id="main"> <a href="#">Click
I have a simple piece of code: public string GenerateRandomString() { string randomString =
I have this simple piece of code: MyObjectContext db = new MyObjectContext(); Person new_person
If I have a simple piece of data to store (an integer or string

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.