Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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
218,861 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
218,861 Points

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