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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:19:36+00:00 2026-06-06T19:19:36+00:00

here is my old code which works: $(‘.logo’).hover(function(){ $(this).addClass(‘animated swing’)}, function(){$(this).removeClass(‘animated swing’) }); here

  • 0

here is my old code which works:

$('.logo').hover(function(){
  $(this).addClass('animated swing')},
  function(){$(this).removeClass('animated swing')
});   

here is my new code that im trying to refactor. the problem is its adding the classes “animated swing” when the page loads (without me hovering over the logo).

$('.logo').on('hover').toggle( function() { $(this).toggleClass('animated swing') });  

it also wont play beyond the first time

  • 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-06T19:19:37+00:00Added an answer on June 6, 2026 at 7:19 pm

    You must change your code. on takes 2 arguments, the event and the function to be executed. It should be something like this:

    $('.logo').on('hover', 
        $(this).toggle( function() { $(this).toggleClass('animated swing') });
    );
    

    When you use .on(‘hover’).toggle(…) in reality you are passing the element forward instead of applying that function to the ‘hover’ listener, so it gets executed as it is interpreted (thus triggering the animation as soon as that line is interpreted instead of waiting for the mouse hover event).

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

Sidebar

Related Questions

NOTE: This is an old question and the answers here no longer works (since
Here is an old add in to quickly comment out HTML code. Maybe I
It is Hallowe'en after all. Here's the problem: I'm maintaining some old-ish J2EE code,
Here is an excerpt from my code: xtype: 'image', src: 'http://www.sencha.com/files/blog/old/blog/wp-content/uploads/2010/06/sencha-logo.png', left: '50%', top:
HI Volks, here is my code block which I want to replace by the
I'm following this [slightly old tutorial for 2d java games here][1]. I have a
Here's the thing: file a.php contains jQuery Tablesorter table. This is the Tablesorter code:
I have in here an old web application written in ASP.Net 2.0 + AJAX.
i have an old codebase here, where they used protected member variables. Whether or
I've deleted the old post here. I have a contentEditable div. If you paste

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.