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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:10:01+00:00 2026-06-01T23:10:01+00:00

i want to fadein div on its text change, i made a small function

  • 0

i want to fadein div on its text change, i made a small function but it is not working. it changing value but not fading it.

$(function(){   
    $('.jqTransformSelectWrapper').find('ul').find('a').click(function(){
        var cityVal= $('.jqTransformSelectWrapper').find('ul').find('.selected').text();
        var capCity= cityVal.toLowerCase();

        if(capCity == "first"){
            $('#flightPrice').text('1').fadeOut('slow');            
        }
    })
})

//html

<a index="1" href="#" class="selected">first</a>

<span id="flightPrice">val</span>
  • 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-01T23:10:02+00:00Added an answer on June 1, 2026 at 11:10 pm

    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"); 
                 $(this).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 want to give different transition effects like : $(div).show(fadeIn) $(div).show(shake) $(div).show(fold) etc How
I have a div I want to fade out, update its content, and then
Hey everybody.I'm appending some divs through a getJSON function but i want to jazz
I want to change the opacity of an object instead of fading in content
jQuery(document).ready(function(){ $(.welcome).fadeOut(9500); $(.freelance).fadeIn(10000); $(.freelance).fadeOut(4500); }); I want the welcome message to fadeOut slowly and
I have a message that I want to fadeIn when a form is successfully
I'm new to jQuery but I managed to get something working. The only thing
I'm trying to fade in / out some text inside a div. I've kept
If I had a div tag inside a repeater, and i want to add
I have a div that I want to appear based on user input (works),

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.