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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:49:23+00:00 2026-05-25T09:49:23+00:00

I have two images with different IDs, lets say #pic1 and #pic2. I tried

  • 0

I have two images with different IDs, lets say #pic1 and #pic2. I tried adding both selectors to a toggle but they both toggle the same element independently, so when you click the first pic and then the second, the second doesn’t toggle the target div back it performs the first part of the toggle a second time. For instance if it’s supposed to slide a 100px to the left and then slide 100px back to the right, clicking #pic1 would slide it 100px left but clicking #pic2 would just slide it 100px to the left again. Can someone give me an idea of what direction I should be looking?

$('#pic1,#pic2').toggle(
function()
{
  $('#mylayer').delay(1000).animate({left: "+=100"});
  $('#overlay').animate({opacity: 0.8});
},
function()
{
  $('#mylayer').animate({left: "-=100"});
  $('#overlay').delay(1000).animate({opacity: 0});
});
  • 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-25T09:49:24+00:00Added an answer on May 25, 2026 at 9:49 am

    Try something like this that keeps track of the open/closed state once for both clicks and uses jQuery’s data capability to avoid using a global variable and to make this more extensible to be used multiple places:

    $('#pic1,#pic2').click() {
        var mylayer = $("#mylayer");
        var open = mylayer.data("open");
        if (open) {
            mylayer.animate({left: "-=100"});
            $('#overlay').delay(1000).animate({opacity: 0});
            mylayer.data("open", false);
        } else {
            mylayer.delay(1000).animate({left: "+=100"});
            $('#overlay').animate({opacity: 0.8});
            mylayer.data("open", true);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two images that are of same size and text but different colors
I have two images which i would like to compare and do different operations
I have two images, both taken at the same time from the same detector.
I have two different products Prod_A and Prod_B on the same page, say www.xyz.com/index1.html
I have two different domains that both point to my homepage in the same
We have two images with different (or not) pictures. How do I check by
I have two different arrays like this var images = [{ src: images2/animal_1.jpg, title:
I have two identical images stored in two different servers (dropbox and my own).
I have two View Controllers: 1. With two buttons with different images. 2. With
I have to show two different images for the corresponding orientations. I have added

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.