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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:05:49+00:00 2026-05-29T11:05:49+00:00

I have written some code which produces simple animations based on cycling through a

  • 0

I have written some code which produces simple animations based on cycling through a load of images, showing one image at a time with the rest hidden. Each frame is shown for 50 milliseconds.

The HTML of the animated element is like this:

<a href="/" id="owl">
  <img class="owl frame active-frame" style="" src="http://example.com/image1">
  <img class="owl frame" style=" display:none;" src="http://thereisspacehere.org/wp-content/themes/twentyeleven/images/animation/owl/2.jpg">
  <img class="owl frame" style=" display:none;" src="http://example.com/image2">
  <img class="owl frame" style=" display:none;" src="http://example.com/image3">
</a>

The CSS looks like this:

#owl {
  position:absolute;
  top:15px;
  left:13px;
  width:154px;
  height:170px;
}
.owl {
  position:absolute;
  top:0;
  left:0;
  width:154px;
  height:170px;
}

The #owl element is positioned absolutely within a relatively positioned div.

The #owl element is a link to ‘/’, but clicking on the animation does nothing. This code:

$('#owl').click(function(){
  console.log('Clicked');
});

Never gets executed when you click on it. Likewise, attaching an onclick event directly to the html of the element doesn’t restore the clickability.

If I make the <a> element bigger than the animated frames inside it, the portion that extends beyond the animation does retain its click event, and the code above runs, and the link is followed.

Why have I lost my click event? How can I get it back, or how can I work around the problem?

Thanks a lot.

Edit – here’s the code that creates the animation. Apologies for length!

Animation = {
    direction: 1,
    iterations: 0,
    maxIterations: 30,
    intervalId: false,
    element: '',
    active: false,
    cycle: function(element, iterations){
        this.element = element;
        $(element).addClass('animation');
        this.maxIterations = iterations;
        if (!this.active){
            this.intervalId = setInterval(function(){ Animation.changeFrame(Animation.element);},50);
            this.active = true;
        }
    },
    changeFrame: function(element){
        if (this.iterations > this.maxIterations){
            this.stop();
            this.revertToStart(element);
            this.active = false;
            this.iterations = 0;
        }
        var el = $(element);
        currentFrame = el.children('.active-frame');
        if (this.direction === 1){
            nextFrame = currentFrame.next('.frame');
        }else{
            nextFrame = currentFrame.prev('.frame');
        }
        if (nextFrame.length == 0){
            this.direction = this.direction ? 0 : 1;
            if (this.direction === 1){
                nextFrame = currentFrame.next('.frame');
            }else{
                nextFrame = currentFrame.prev('.frame');
            }
        }
        currentFrame.hide().removeClass('active-frame');
        nextFrame.show().addClass('active-frame');
        this.iterations++;
    },
    stop: function(){
        clearInterval(this.intervalId);
    },
    revertToStart: function(element){
        $(element).children('.frame').removeClass('active-frame');
        $(element).children('.frame').hide();
        $(element).children('.frame:first').show().addClass('active-frame');
    }
};
$(function(){
    $('#owl .frame:first').addClass('active-frame');
    $('#owl').mouseover(function(){
        Animation.cycle('#owl', 29);
    });
    $('#owl').click(function(){
        console.log('hey');
    })
});
  • 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-29T11:05:50+00:00Added an answer on May 29, 2026 at 11:05 am

    I have no idea why click doesn’t work, but I have solution. You can add additional transparent element on the top, and then everything will work.

    Working sample: http://jsfiddle.net/lolo/pJ5sE/1/

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

Sidebar

Related Questions

I have some code I've written in PHP for consuming our simple webservice, which
I have written some code which performs a Monte Carlo simulation and produces curves
I have written some code for playing a .wav through my application. Now I
I have written some code which passes values between java and c using jni.
I have written some code which compiles fine under linux but on Solaris I
I have written some code in which a small part of the code takes
Context: Windows7, VBScript, ADODB and ADOX. I have written some VBScript code which creates
I have written some code which works without errors. The code uses MySQLdb for
I have written some code which checks a site for broken links using the
I have written some code which extracts and invoice from various hashes, arrays, arrays

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.