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

cathymacars
cathymacars
15,335 Points

Including jQuery in our Project 5/5

The question: Within the anonymous function write the code to remove the element that’s clicked from the document.

My answer:

$(".removable").click(
    function(){
        this.remove();
    }
);

Why doesn't this get accepted? It even works in the right panel; when I click the items, they get removed.
I think it might be a bug, because this is the error message I get "Bummer! null".

8 Answers

samiff
samiff
31,206 Points

$(this) vs this

Also, to format code here in the forums, you can add three backticks(`) before and after your code block.

Craig you don't need ".all()" When you select the class removable in your selector " $(".removable") " you're selecting them all.

I'm stuck on Question #4 and hate being held up. Here's what I've got, and no I still haven't figured out how to show the entire code but...

Question: Add a click event listener with an anonymous function to the selected "removable" elements. Error Message: You need to call 'click()' on '$(".removable")' and enter in an anonymous function. My Code within the <script type="text/javascript"> </script> tags: $("#message").hide().show("slow"); =>>> $(".removable").click("eventObject"); </script>

I've also tried $(".removable").click(); and neither of them work. Any help would be greatly appreciated.

Also I posted this to Facebook so the =>>> isn't a PHP reference not that it would even be PHP but I was just pointing out the specific line of code.

Got it Nevermind

I'm a bit stuck on #4 as well, here is my code

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$("#message").hide().show("slow");
$(".removable").all().click(function() {
});
</script>

Any help please?

Thanks Raj!

$(".removable").click(function() { $(".removable").select(); });