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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:15:19+00:00 2026-05-28T02:15:19+00:00

I have a jsFiddle setup to where you will be able to click on

  • 0

I have a jsFiddle setup to where you will be able to click on the image to the left and when you do it changes the image, but when you click on the DIV as an entirety (expand-one) it does not swap the image out.

I want to be able to click on a DIV (as a whole) and swap out an image that is within the DIV without having only being able to click on just the image.

You can view what I mean here:
http://jsfiddle.net/5PDV5/1/

Thank you all! 🙂

  • 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-28T02:15:19+00:00Added an answer on May 28, 2026 at 2:15 am

    All you need to do is inside the click handler for the div change the image’s src.

    jQuery('.expand-one').click(function(){
            jQuery('.content-one').slideToggle('fast');
            var img = $(this).find('img'),
                src = img.attr("src")
                alt = img.data("altsrc");
                img.attr("src",alt).data("altsrc",src);
        });
        jQuery('.expand-one').toggle(function() {
            jQuery('.content-one').slideDown('fast');
            }, function() {
            jQuery('.content-one').slideUp('fast');
        });
    

    Also a more efficient method would be to use classes and background images so the code would read like:

    HTML

    <div class="expand-one blue-icon"></div>
    

    CSS

    .expand-one { margin-left: 5px } /* Margin of Icon Size */
    .blue-icon { background-image: url('blue-icon.png'); }
    .green-icon { background-image: url('green-icon.png'); }
    

    JS

    //This turns one off and the other on
    $(this).toggleClass('blue-icon green-icon');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an expand and collapse system setup in jQuery/JavaScript. Once you click on
My setup: http://jsfiddle.net/ASa2K/1/ I have a Jquery Infinite Carousel which will have in it
I have the following jsfiddle setup: http://jsfiddle.net/cvn6n/ Based on the radio selection a div
Ok, if you go here: http://jsfiddle.net/RarFB/2/ You will see the work that I have
I have a form setup but for some reason the JS to submit the
I have setup some code on JSFiddle. The jQuery :contains selector works fine in
I have the following setup: A sortable list where one of the <li> has
I have the following jsfiddle setup: http://jsfiddle.net/zZDqH/ Currently it is just a button that
Suppose I have markup as setup http://jsfiddle.net/ADxne/ Currently drop downs look like To solve
The description is kind of confusing, but I have two divs. One which sits

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.