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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:02:09+00:00 2026-06-02T18:02:09+00:00

I’m fairly new to using JQuery and was just playing around. I’m trying to

  • 0

I’m fairly new to using JQuery and was just playing around. I’m trying to have an element fade in on the click of a button. If the users clicks the button again, while the element is still fading in, I want it to start hidden/invisible again. So I first stop all animations stop(true) then hide the element an let it fade in.

I can’t get it to work though. It seems like the second fade in starts with the opacity the element has at that moment and fades in from there. I’ve also tried to use css("opacity", 0) in stead of hide() but then the element just gets it’s opacity set to 0 and fadeIn doesn’t seem to work anymore.

<html>
    <head>
        <script src="http://code.jquery.com/jquery-latest.js"> </script>
    </head>
    <body>
        <script type="text/javascript">
            $(document).ready(function () {
                $("button").click(function () {
                    $("span").stop(true).hide().fadeIn(3000);
                });
            })
        </script>
        <button>FadeIn</button> <span>Hello, world!</span>
    </body>
</html>

Using JQuery 1.7.2 and tried in Chrome and IE.

What am I doing wrong?

  • 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-02T18:02:10+00:00Added an answer on June 2, 2026 at 6:02 pm

    .stop(true) just stops the animation and leaves it wherever it was. If you were in the middle of a fade(), then the object will be left with an opacity value in the middle of the fade.

    If you want to stop the animation and put the opacity in a known state, then you probably just want to set it to what you want it to start at. .hide() sets display: none – it doesn’t mess with the opacity.

    So, if you were in the middle of a fadeOut() when you did the .stop(true), then you could just do .stop(true, true) and that will jump the current animation to the end, thus giving you a good place to start your fadeIn() from.

    You could also stop the animation where it was and then fade from there to your full opacity with:

    .stop(true).fadeTo(3000, 1);
    

    which is more generally what you want to do when you’re interrupting the previous animation.

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have thousands of HTML files to process using Groovy/Java and I need to
I am trying to loop through a bunch of documents I have to put
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has

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.