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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:27:27+00:00 2026-06-12T07:27:27+00:00

I have a working toggle spoiler – thanks for adrian for the code. It

  • 0

I have a working toggle spoiler – thanks for adrian for the code.
It closes instantly when opening another spoiler.

I added a plus image on the right, and i want the plus change into minus a image once opened and then change back to plus once closed or switched spoiler.

This is what I have currently:

http://justxp.plutohost.net/slyfiles/index.html

How do i make the plus image turn into a minus image on spoiler toggle and change back on spoiler toggle close?

My codes:

 <div id="spoiler1" data-hidden="hide1" class="spoiler"><span class="featurelist_2-text-margin">Networks</span><div id="plus"><img src="http://cdn4.iconfinder.com/data/icons/iconic/raster/12/plus.png"></div>
 </div>
<div id="hide1" class="hide"><p id="texting1">We have a very security system, including secure logging in, management, balance management and more. 
We do a SQL backup every hour to protect us from our data being lost.</p></div>

<div id="spoiler2" data-hidden="hide2" class="spoiler"><span class="featurelist_2-text-margin">Payment Avarge</span></div>
<div id="hide2" class="hide"><p id="texting1">We have a very security system, including secure logging in, management, balance management and more. 
We do a SQL backup every hour to protect us from our data being lost.</p></div>


<div id="spoiler3" data-hidden="hide3" class="spoiler"><span class="featurelist_2-text-margin">Control Panel - SlyPanel</span></div>
<div id="hide3" class="hide"><p id="texting1">We have a very security system, including secure logging in, management, balance management and more. 
We do a SQL backup every hour to protect us from our data being lost.</p></div>

<div id="spoiler4" data-hidden="hide4" class="spoiler"><span class="featurelist_2-text-margin">Security</span></div>
<div id="hide4" class="hide"><p id="texting1">We have a very security system, including secure logging in, management, balance management and more. 
We do a SQL backup every hour to protect us from our data being lost.</p>
</div> 

JS:

<script>
$('.spoiler').click(function() {
    var hiddenid = $(this).data('hidden');
    $('#' + hiddenid).slideToggle();
    $('.hide:not(#' + hiddenid + ')').slideUp();
});
</script>

CSS

.featurelist_2-text-margin{
    margin-top: 10px;
    position: absolute;
    margin-left: 20px;
    text-align: left;
    color: #259acb;
}

.spoiler {
        font-size: 16px;
    background-color: #c0e6d2;
    border: 1px solid #a7c8b7;
    height: 45px;
    width: 530px;
        text-shadow: 0px 1px 0px #f4f4f4;
        filter: dropshadow(color=#fff, offx=0, offy=1);
                margin-top: 3px;
                cursor: pointer;
                    min-width: 511px;
                        position: relative;
}

.hide{
    font-size: 15px;
    background-color: #dedede;
    border: 1px solid #c1c1c1;
    width: 530px;
    height: auto;
    color: #262626;
        text-shadow: 0px 1px 0px #f4f4f4;
        filter: dropshadow(color=#fff, offx=0, offy=1);
                margin-top: 3px;
    display: none;
}

#plus {
float: right;
margin-top: 17px;
margin-right: 10px;
}

Hide1,2,3,4 are empty.

Live preview: http://justxp.plutohost.net/slyfiles/index.html

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-06-12T07:27:29+00:00Added an answer on June 12, 2026 at 7:27 am

    Try this..

    $('.spoiler').click(function() {
        var hiddenid = $(this).data('hidden');
        $('#' + hiddenid).slideToggle();
        $('.hide:not(#' + hiddenid + ')').slideUp();
    
        var $img = $(this).find('img');
        if( $img.attr('src').indexOf('plus') > -1){
    
           $img.attr('src', 'http://cdn4.iconfinder.com/data/icons/iconic/raster/12/minus.png')
        }
        else{
           $img.attr('src', 'http://cdn4.iconfinder.com/data/icons/iconic/raster/12/plus.png')
        }
    
    });
    

    I am assuming the src of the images to end with plus.png and minus.png

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

Sidebar

Related Questions

I have a show/hide toggle working well in multiple instances (thanks to help here
I have working with a project and i added a share button to product
I have working code of js, it shows different div for selected option. <html>
I have a script working to show hide the next() tbody element when another
I have this script which is working fine: $('a.clickMe').click(function () { id = $(this).attr('toggle');
I have a code that adds a check-all toggle to each of my buttons
I already have taglist working well. When I press the binding for the toggle
I have this code working on Safari and Chrome , but not in Firefox
I have a dropdown menu working great with the following code: $('#menu ul li').mouseenter(function(){
I have a jquery code(toggel) which is working fine in IE6 but not in

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.