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.

codekudos
15,267 PointsjQuery $(this) selector not working.
$('.spoiler').on('click', 'button', (evt) => {
//show the spoiler text
$(this).prev().show();
//hide the "reveal"
$(this).hide();
});
I tried using various browsers. I am able to use $(evt.target) with no issues
4 Answers

Balazs Peak
46,121 PointsYour code looks fine, though. I'd suggest to keep progressing with the lectures. You will know much more about the "this" keyword later on.

Andrew Karas
7,967 Pointsyou will need to use function (e) {} instead of (e) => {}

Jeff Sanders
Courses Plus Student 9,428 PointsFrom MDN: "An arrow function expression has a shorter syntax than a function expression and does not have its own this, arguments, super, or new.target."
I also highly recommend reading this article: http://2ality.com/2012/04/arrow-functions.html and this https://dmitripavlutin.com/when-not-to-use-arrow-functions-in-javascript/
The "this" that you are selecting in your arrow function expression is actually 'Window'.

Bibiana Balbuena Barbosa
14,768 PointsI had the same problem, this was helpfull, tks!

Tai Man Chan
Courses Plus Student 135 Pointsbecoz you're using anonymous function