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 trialVamsi Pavan Mahesh Gunturu
4,541 PointsI am unable to hide the element using hide() in workspace
Here is my snapshot https://w.trhou.se/pfhficoy40
4 Answers
Adrian Randall
4,807 PointsWrap it in document ready..the DOM element probably isnt loaded when that JS is called
$( document ).ready(function() { $(".warning").hide() });
Tim Knight
28,888 PointsVamsi,
You want to make sure you jQuery code isn't running until the document is fully loaded, that's probably what's happening here.
So instead of just:
$(".warning").hide()
Try this:
$(function () {
$(".warning").hide();
});
Adrian Randall
4,807 Points@Tim isn't that just an anonymous function?
I could be wrong but I always check the document is ready
Tim Knight
28,888 PointsIn this case it's really just shorthand for the domready check.
See: http://www.unseenrevolution.com/jquery-document-ready-shorthand/
Adrian Randall
4,807 PointsTim Knight - I did not know that, been doing the doc ready for years!
Cheers
Michael Singleton
6,253 Pointsit looks like you are forgetting semicolon