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

cathymacars
seal-mask
.a{fill-rule:evenodd;}techdegree
cathymacars
Full Stack JavaScript Techdegree Student 15,941 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(); });