Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML

Shariq Shaikh
Shariq Shaikh
13,945 Points

Using hide("slow") instead of remove() as experiment does not run as smoothly as I would like, any suggestions?

I was playing around with the code for this project and wanted to see if I could make the button disappear slowly the way we made "its a trap appear, and although the button does disappear slowly it does so in a choppy manner, can anyone think of a way to make it disappear more smoothly?

Shariq Shaikh
Shariq Shaikh
13,945 Points

The correct solution is in the last comment of the selected best answer

1 Answer

Hugo Paz
Hugo Paz
15,622 Points

Here is a suggestion. Use fadeOut() to make the button transparent. When the animation ends, the button display is set to none so you dont have to remove it.

Shariq Shaikh
Shariq Shaikh
13,945 Points

When I tried that, the button shifted downward the same way it did at the beginning of the project before fading out

Hugo Paz
Hugo Paz
15,622 Points

I see what you mean. Now I am curious.

Hugo Paz
Hugo Paz
15,622 Points

Ok i think i found a way, try this code on the hidespoilers projects.

$("button").click(function(){
  //3.1, Get rid of button
  $(this).fadeOut("slow", function(){
  //3.2, Show spoiler next to the button clicked   
  $(this).prev().show();
  });  
});