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

  • SEARCH
  • Home
  • 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 6026125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:24:02+00:00 2026-05-23T04:24:02+00:00

So I’m a beginner at this whole javascript thing, and this is probably a

  • 0

So I’m a beginner at this whole javascript thing, and this is probably a really beginner question. I’ve been searching all over for the answer and even tried modifying source code for some basic accordions, but it never works.

Basically I want to write a function that when you click a thumbnail, the image expands. I’ve got that part down, what I can’t figure out is how to then when you click on another image, the first image goes back to being a thumbnail while the newly clicked image expands. I would like there to be an animation quality to it, but I’ll just be happy with the basic functionality, and maybe I can work out how to animate it myself. My image gallery is in an unordered list, with each image set as a list item, and I’m trying to use jquery to do this.

thanks in advance!!

here’s what I have making have images larger when you click:

$('ul#live li img').click(function() {
    $(this).animate({
        'width': '515px',
        'height':'100%' 
    });
});

my css:

ul#live li img {
width:120px;
height:72px;
}

that’s it.
now all I want is to be able to click on another image and have the first image clicked go back to it’s original 120px width. That’s it. I’m not trying to have it removed from the flow, or in any sort of lightbox. The way I’m doing it is probably not the best way, I’m just learning and experimenting. Hope this clears things up.

  • 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-23T04:24:02+00:00Added an answer on May 23, 2026 at 4:24 am

    it can be done fairly straight forward. What i’ve done in the past with similar is give the expanded element a new class $(this).addClass('active_element');

    You can then add an animation so that when the next item is clicked, any with .active_element is affected first – run your animation, remove the class and then run the effect for the newly selected element.

    $('ul#live li img').click(function() {
        $('.active_element').animate({
    
        //close animation goes here
    
        });
        $('.active_element').removeClass('active_element');
    
        $(this).animate({
            'width': '515px',
            'height':'100%' 
        });
    
        $(this).addClass('active_element');
    
    });
    

    This can be written a little neater, but that’s the basic principle spelled out step by step.

    it’s down and dirty, but will do the job.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

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.