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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T19:44:30+00:00 2026-05-20T19:44:30+00:00

I am playing around with animating text when clicked. I have buttons with various

  • 0

I am playing around with animating text when clicked.

I have buttons with various classes that define size :

<div class="button-1">Click Me!</div>
<div class="button-2">Click Me!</div>
<div class="button-3">Click Me!</div>

.button-1 {font-size: 10px;}
.button-2 {font-size: 20px;}
.button-3 {font-size: 30px;}

Then when one is clicked it is animated to a bigger size.

    $('.button-1,.button-2,.button-3').click(function(){
    $(this).animate({fontSize: "40px" }, 1000 );

My question is I only want to have one big at a time and have all of the siblings return to their original size. I see the animate function works by adding an inline style to the text, is there a way I can just delete out all of the inline styles appended to the clicked buttons siblings?

  • 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-20T19:44:31+00:00Added an answer on May 20, 2026 at 7:44 pm

    This works and looks much better…

    $(document).ready(function() {
        $('.button-1,.button-2,.button-3').each(function() {
    
            $(this).data('original-size', $(this).css('fontSize'));
    
            $(this).click(function() {
    
                $(this).animate({
                    fontSize: "40px"
                }, 1000);
    
                $(this).siblings().each(function() {
    
                    var originalSize = $(this).data('original-size');
    
                    if ($(this).css('fontSize') != originalSize) {
    
                        $(this).animate({
                            fontSize: originalSize
                        }, 500);
                    }
                });
    
            });
        });
    });
    

    jsFiddle.

    If you were lazy, you could also do…

    $(this).siblings().removeAttr('style')
    

    jsFiddle.

    This solution, however, is flaky and could lean to painful debugging if you or jQuery adds extra styles via the style attribute. I recommend you use the former code.

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

Sidebar

Related Questions

Playing around with MSVC++ 2005, I noticed that if the same class is defined
I have been playing around with the concept of 'module' that some mvc frameworks
I'm playing around with the <canvas> element, drawing lines and such. I've noticed that
I am playing around with MVC and have started setting up an existing site
I was playing around with storyboards, a flipping animation, and visual brushes. I have
I have been playing around with jQuery for a bit now, and am really
Started playing around with jQuery and the jsTree plugin yesterday, and have it successfully
I've been playing around trying to create a transparent window that will overlay another
I have been playing around with the dynamic abilities of powershell and I was
I'm new to html5 and have been playing around with the canvas. I'm wondering

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.