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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:42:16+00:00 2026-06-05T14:42:16+00:00

I am trying to create a function in JQuery which animates a couple links

  • 0

I am trying to create a function in JQuery which animates a couple links between their non-hovered and hover states indefinitely until my abortTimer function is fired. I would like to animate between a.mus-plr and a.earbuds at opposing times, so when one of the elements has it’s '.hover' class enabled, the other would not have it’s '.hover' class enabled. I would like each element to switch between it’s hover states every 3000 milliseconds.

Any help would be much appreciated! I can’t seem to get this to work. I’m thinking it might be a problem with how I’ve defined my setInterval timer. Thanks!!

JQuery file:

$(document).ready(function(){
    var tid = setInterval(animateControls, 4000);
    function animateControls() {
        $("a.mus-plr").delay(2000).addClass('hover').delay(2000).removeClass('hover');
        $("a.earbuds").addClass('hover').delay(2000).removeClass('hover');
    }
    function abortTimer() {
        clearInterval(tid);
    }
});
  • 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-06-05T14:42:19+00:00Added an answer on June 5, 2026 at 2:42 pm

    You simply toggle the hover class each time your interval timer expires, assuming they start off with one having and the other not having the hover class.

    Edited to stop the automated toggle when an element is hovered.

    $(function() {
         var doToggle = true;
    
         $('a.mus-plr').removeClass('hover');
         $('a.earbuds').addClass('hover');
    
         var tid = setInterval( function() {
              if (doToggle) $('a.mus-plr, a.earbuds').toggleClass('hover');
         }, 2000);
    
         setTimeout(function() {
            if (tid) clearInterval(tid);
            $('a.mus-plr,a.earbuds').removeClass('hover');
         }, 30000); // stop toggling after 30 seconds
    
         $('a.mus-plr,a.earbuds').hover( function() {
               doToggle = false;
         }, function() {
               doToggle = true;
         });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a popup for which I am using jQuery's CSS function.Here's
I am trying to create a custom jquery function which has two parameters, the
I'm trying to create a JQuery function that will test a string for the
I am trying to create a function which will give me alphabet position when
I'm trying to create my custom toolbox which imitates jQuery's design pattern. Basically, the
I'm trying to create a module in joomla, which uses one jquery plugin. I've
I'm trying to create a jQuery widget which extends from ui.slider . I'd like
I am trying to create my first own jQuery function to re-order some rows
I am trying to create some jquery styled hover fade in/out thumbnails. I've managed
I am trying to create a small animated effect with jquery in which images

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.