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

  • Home
  • SEARCH
  • 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 4542440
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T15:23:28+00:00 2026-05-21T15:23:28+00:00

Say a element has value 55: <span id=some>55</span> I want to: fade out the

  • 0

Say a element has value 55:

<span id="some">55</span>

I want to:

  1. fade out the element
  2. set value 44
  3. fade in the element

So I tried:

$("#some").fadeOut("slow").html("44").fadeIn("slow");

But the above first sets the span’s content to 44, and then fades out and fades in.

So I tried with a callback:

function fadeOutComplete(){
  $("#some").html("<%= @cc %>").fadeIn("slow");
}
$("#some").fadeOut("slow",fadeOutComplete);

Now this works, but it’s looks and feels clunky. Is there some way to write this DRYer and more jQuery-er? (not even sure what I mean by jQuery-er!)

How could I pass in the element whose value is to be set and the value to be set to fadeOutComplete so I can make that callback sort-of generic?

  • 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-21T15:23:29+00:00Added an answer on May 21, 2026 at 3:23 pm

    Check this…

    $("#some").fadeOut("slow", function() {
       $(this).html("<%= @cc %>").fadeIn("slow");
    });
    
    • You can pass an anonymous function, to prevent registering a named function that will no doubt only be used once.
    • Inside the callback of the complete for fadeOut(), this is pointing to the native DOM element. This allows you to reference it again in a DRY way.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say you want to allow some particular XML element to occur 0+ times.
Say I have the following element: <p id=thingy>Here is some <em>emphasized</em> text!</p> In a
Okay so say I have a form element like this: HTML: <div class=form-item> <label>Current
Say if I have an array and I want to check if an element
I'm having some difficulties with getting the value of a subclass in a element.
If you have an XML schema which dictates an element has a default value,
How te remove an element from TCL list say: which has index = 4
Let's say I have a large collection of elements. Each element has a position
Lets say if I have a vector V, which has 10 elements. If I
Say I have a vector which has thousands of elements. What is the R

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.