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

JavaScript jQuery Basics (2014) Introduction to jQuery What is jQuery?

Katharine Cooney
Katharine Cooney
4,612 Points

Issue with the Hide Function

When I use the hide function and preview the page, the warning appears for maybe half a second and THEN hides. I tried previewing the page on both Chrome and IE and both have the same issue. Does anyone know how to fix this? This is my code (I think it's identical to the code in the video!)

//Hide warning jQuery(".warning").hide(); //Show warning slowly jQuery(".warning").show("slow");

1 Answer

Steven Parker
Steven Parker
229,644 Points

This would be a good place to use CSS.

To avoid "flashing" the element you want initially hidden, you can use CSS to hide it instead of JavaScript, like this:

style.css
.warning { display: none; }

You can still use the JavaScript for the slow reveal using show.

nico dev
nico dev
20,364 Points

Thank you!!

I learn so much with your answers, and I thought I had to say 'Thank you'.

And this really seemed to me the perfect answer/place to say it.

Steven Parker
Steven Parker
229,644 Points

I appreciate your comments Nico Trivelli, happy to help. :smile: