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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:50:36+00:00 2026-05-30T03:50:36+00:00

$(document).ready(function() { $(‘.button’).hover(function() { $(this).toggleClass(‘button-hover’,200); },function() { $(this).toggleClass(‘button-hover’,200); }); }); $(document).ready(function() { $(‘.button-rounded’).hover(function() {

  • 0
$(document).ready(function() {
    $('.button').hover(function() {
        $(this).toggleClass('button-hover',200);
    },function() {
        $(this).toggleClass('button-hover',200);
    });
});
$(document).ready(function() {
    $('.button-rounded').hover(function() {
        $(this).toggleClass('button-rounded-hover',200);
    },function() {
        $(this).toggleClass('button-rounded-hover',200);
    });
});

<div class="button">Add class `button-hover` to this `div` on mouse over.</div>
<div class="button button-rounded">Add class `button-hover` and 
    class `button-rounded-hover` to this `div` on mouse over.</div>

On the second div, it takes 400 ms to do the whole animation: 200 for the button-hover toggle, and then another 200 for the button-rounded-hover toggle. How do I perform these toggles simultaneously?

Notes:

  • I’m using OOCSS, so button-rounded extends button, and button-rounded-hover extends button-hover. I don’t want to define button-rounded-hover almost exactly like button-hover because that wouldn’t be very DRY (Don’t Repeat Yourself) so that’s why I’m using two classes and two hover calls on the second div.
  • Both actions need to take 200ms. I don’t want to make either of them 0 (instantaneous).
  • 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-30T03:50:38+00:00Added an answer on May 30, 2026 at 3:50 am

    If every element that has .button-rounded class also have .button class (that’s what I understood by “button-rounded extends button”), you should only add a hover handle to button, and select the class to be toggled based on whether or not your element has button-rounded class. Example:

    $(document).ready(function() {
        $('.button').hover(function() {
            $(this).toggleClass(
                ($(this).hasClass('button-rounded') ? 'button-rounded-hover ' : '') +
                'button-hover',
                200
            );
        });
    });
    

    toggleClass also accpets a list of classes separated by spaces, so you can toggle multiple classes simultaneously that way.

    Note: since both “over” and “out” functions are equals, you can use a single one and it will apply to both events.

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

Sidebar

Related Questions

jQuery(document).ready(function(){ $(function() { $('.button-a').each(function() { $(this).hover( function () { $('.button-title', this).animate({ opacity: 0.6 },
$(document).ready(function() { var $clickable_pieces = $('.chess_piece').parent(); $($clickable_pieces).addClass('selectee'); // add selectee class var $selectee =
$(document).ready(function() { $(#register button[name=btnPosta]).click(function() { console.log('clicked'); thisBtn = $(this); parent = $(this).parent(); name =
$(document).ready(function() { $(#register button[name=btnPosta]).click(function() { console.log('clicked'); thisBtn = $(this); parent = $(this).parent(); name =
$(document).ready(function() { $('#chkRFI').click( function() { $(INPUT[type='checkbox']).attr('checked', $('#chkRFI').is(':checked')); }); }); <div class=grid_3> <div class=box> <div
$(document).ready(function() { $([class^='count[']).each(function() { var elClass = $(this).attr('class'); var minWords = 0; var maxWords
jQuery(document).ready(function(){ var panelContainer = jQuery('div#panels'); jQuery('<div id=tabs></div>').insertBefore(panelContainer); panelContainer.find('div.panel').each(function(n){ jQuery('div#tabs').append('<a class=tab href=#' + (n+1) +
$(document).ready(function(){ $('#button').click(function(){ $('.accordion').load('<iframe src=google.com frameborder=0 scrolling=no id=myFrame></iframe>'); }); }); This can't display the iframe
$(document).ready(function() { $('#promotion_profile_booking_description').keyup(function () { var left = 200 - $(this).val().length; if (left <
$(document).ready(function() { $(span.link).mouseover(function(e){ $(this.children).css(display,inline); }); }); I'm not a javascript expert, but I've cobbled

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.