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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:03:23+00:00 2026-05-23T01:03:23+00:00

I have a div with a CSS style to show it as a button:

  • 0

I have a div with a CSS style to show it as a button:

<div id="Word1" class="btn green" onclick="WordClicked(1);">Word 1</div>

And CSS styles:

.btn {
    display: inline-block;
    background: url(btn.bg.png) repeat-x 0px 0px;
    padding: 5px 10px 6px 10px;
    font-weight: bold;
    text-shadow: 1px 1px 1px rgba(255,255,255,0.5);
    text-align: center;
    border: 1px solid rgba(0,0,0,0.4);
    -moz-border-radius: 5px;
    -moz-box-shadow: 0px 0px 2px rgba(0,0,0,0.5);
    -webkit-border-radius: 5px;
    -webkit-box-shadow: 0px 0px 2px rgba(0,0,0,0.5);
}

.green      {background-color: #CCCCCC; color: #141414;}

I want to fade out text inside div, change text, and then fade in text again. But I don’t want to fade in and fade out div.

If I use this javascript code:

$('#Word1').fadeOut('fast');

I will fade out div and text inside.

How can I do that?

  • 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-23T01:03:24+00:00Added an answer on May 23, 2026 at 1:03 am

    You want to wrap the text in a span then fade that out:

    <div class="button"><span>TEXT!</span></div>
    

    and you don’t want to use fadeOut because that will change the size of your button as the text will disappear once fadeOut ends and no longer take up space. Instead animate the opacity:

    $(".button").click(function(){
        $(this).find("span").animate({opacity:0},function(){
            $(this).text("new text")
                .animate({opacity:1});  
        })
    });
    

    http://jsfiddle.net/8Dtr6/

    EDIT: Slight correction, as long as you immediately fade back in it does not seem to be an issue to use fadeIn and fadeOut, at least in chrome. I would expect maybe in lesser browsers to see a slight flicker, but could be wrong.

    Possibly a bit cleaner using queue to avoid callbacks:

    $(".button").click(function(){
        $(this).find("span")
            .animate({opacity:0})
            .queue(function(){
                 $(this).text("new text")
                        .dequeue()
            })
            .animate({opacity:1});  
    });
    

    http://jsfiddle.net/8Dtr6/2

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

Sidebar

Related Questions

I have a div tag styled through CSS. I set the padding to 10px
If you have several div s on a page, you can use CSS to
I have a div with overflow:hidden , inside which I show a phone number
I have a div container and have defined its style as follows: div#tbl-container {
jQuery uses the CSS display property under the hood of the simple show() and
I have a really simple external css stylesheet that has the following : div.hideBox
I have div containing a list of flash objects. The list is long so
I have a div and an iframe on the page the div has z-index:
I have a div in which a page is loaded with the DojoX Layout
I have a div with a <h1> tag in a div, with no margins.

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.