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

Not sure if my jquery is correct, and I could use some pointers. (codepen included).

I made a website that has a image fade into view, and a click handler that reveals a little more info about sea lions. Can some check to see if the code I've written in my jquery is okay? I'm not sure if I did it all correctly, this is really my first try at writing my own jquery, I usually would just use plugins, and other things. Also, did I repeat myself in line 2 and 3 of my codepen?

Thank you for any help.

codepen: http://codepen.io/mike316/pen/akXymE

1 Answer

Steven Parker
Steven Parker
243,318 Points

Your jQuery looks pretty good! :+1:

But you might consider setting the initial invisibility in CSS ("display: none") rather than using hide(), since the latter might briefly expose the items as the page loads.

And you didn't repeat yourself, as those lines do different things. But you could consolidate them like this:

    $(".fade-out").hide().fadeIn(5000);

What happens if the user doesn't have JavaScript enabled on their browser, won't using the .hide() allow them to see picture. Thanks for the reply.