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

Just not getting it. JQuery

Here are the instructions:

Now that we've reviewed our jQuery event handlers, let's learn a new one.

We might want to cause a jQuery effect when a user double clicks on an element, rather than just single-clicking. We can do this with the .dblclick() event handler. Instructions

Use the .dblclick() handler to make our 'div' .fadeOut()s 'fast'. Make sure to double-click on your div to see the effect! ? Hint

Your code should look something like this:

$(document).ready(function() { $('elem').event(function() { $(this).effect('speed'); }); });

Where 'elem' is the HTML element you want to click, event is your .dblclick() event, effect is your fadeOut, and your 'speed' is 'fast'!

Here is my code:

$(document).ready(function(){ $('div').dblclick(function(){ $(this).fadeOut('fast'); }); });

This code is not working. why?

4 Answers

Yes, it definitely should. And the code as you wrote it does work. Perhaps you need to include jquery in your project in order for it to work? Try the CDN just before the closing body tag of your html:

<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>

Hi there, Gary. I'm not sure what's wrong. I did test your code and it works just fine! What course is this challenge a part of?

codeacademy. But I even built it using the teamtreehouse workspace and its still not working. Is not this suppose to be double clicked on and then it fades outs?

I just helped one of my students on this! You have to double click the blue div and wait a few seconds to make it pass on CodeAcademy.

If you double click on it and it doesn't disappear, then something is wrong with your jQuery.

What do you mean by something being wrong with my jQuery? Do you mean my code?