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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:14:02+00:00 2026-05-18T21:14:02+00:00

First, some visualization of the code. I have the following images that are dynamically

  • 0

First, some visualization of the code.
I have the following images that are dynamically generated from jquery. They’re made upon user request:

<img id="i13133" src="someimage.jpg" />
<img id="i13232" src="someimage1.jpg" />
<img id="i14432" src="someimage2.jpg" />
<img id="i16432" src="someimage3.jpg" />
<img id="i18422" src="someimage4.jpg" />

I have an AJAX loop that repeats every 15 seconds using jQuery and it contains the following code:

Note: The if statement is inside the Ajax loop.

Where imgId is the requested ID from the Ajax call.

//Passes the IDs retrieved from Ajax, if the IDs exist on the page the animation is triggered.
if ( $('#i' + imgId ).length )
{

var pickimage = '#i' + imgId;

var stop = false;

function highlight(pickimage) {
   $(pickimage).animate({color: "yellow"}, 1000, function () {
      $(pickimage ).animate({color: "black"}, 1000, function () {
         if (!stop) highlight(pickimage);
      });
   });
}

// Start the loop
highlight(pickimage);

}

It works great, even with multiple images. But I had originally used this with one image.

The problem is I need an interrupt. Something like:

$(img).click(function () {
   stop = true;
});

There’s two problems:

1.)This obviously stops all animations. I can’t wrap my head around how I could write something that only stops the animation of the image that’s clicked.

2.)The Ajax retrieves IDs, sometimes those IDs appear more than once every few minutes, which means it would repeat the animations on top of each other if the image exists. I could use some help figuring out how to detect if an animation is already running on an image, and do nothing if the animation is already triggered on an image.

  • 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-18T21:14:03+00:00Added an answer on May 18, 2026 at 9:14 pm

    You can hit two birds with one stone 😉

    1) Don’t use the stop variable. Add a class to each img:

    // Instead of: var stop = false;
    $(pickimage).addClass("animating");
    
    // Instead of: if (!stop) highlight(pickimage);
    if ($(pickimage).hasClass("animating")) highlight(pickimage);
    
    // Instead of: $(img).click(function () { stop = true; });
    $(img).click(function () { $(this).removeClass("animating"); });
    

    2) Same thing, check the class!

    if ($(pickimage).hasClass("animating")) return;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some code that first selects an option value in a dropdown menu
first some code: I have many elements like that: <section class=item> <div class=caption> </div>
I just declared some code-first models for a new project that uses EntityFramework. public
I have two CSS rules following each other: .some td:first-child:before { content:url('path/to/image.png') ; }
I have created an R script that it needs to load some libraries first.
First some background: I already have a Result class that I've implemented to carry
I have wired experience with reflections. At first some sample code: public abstract class
I have this annoying problem with Internet Explorer. First some code, so it will
I have problem with passing variables through views. But, first some code // i
i am a newbie on web development, so i have some problems first of

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.