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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Myles Gleeson](https://secure.gravatar.com/avatar/98aa39517961dd0f8a33380473de4300?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Myles Gleeson
2,906 PointsWhy can't you access event.target directly?
$('.spoiler').on('click', 'button', function(event){
console.log(event.target);
// Show the spoiler text
$('.spoiler span').show();
// Hide "reveal spoiler" button
$(event.target).hide();
});
Why can't you hide the reveal spoiler button using simply event.target.hide() ?
![Myles Gleeson](https://secure.gravatar.com/avatar/98aa39517961dd0f8a33380473de4300?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Myles Gleeson
2,906 PointsSorry, the code was from the video before the challenge https://teamtreehouse.com/library/the-event-object-3
2 Answers
![Justin Cantley](https://uploads.teamtreehouse.com/production/profile-photos/8338792/micro_justins_head1.jpg)
Justin Cantley
18,068 Points.hide() is a method that can only be called on a jQuery object.
Therefore, the only way to call .hide() on event.target is to first convert event.target into a jQuery object.
![andren](https://secure.gravatar.com/avatar/229e60726cd92951c31d7303e40be2cd?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
andren
28,558 PointsJustin Cantley's answer is right.
To reiterate hide
is a method that belongs to jQuery, it is not a method built into JavaScript's HTMLElement
object. That is why you cannot call it directly on event.target
.
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsThe methods and properties available on HTML elements are different from those on jQuery objects.
Here's a "direct" way to conceal an HTML element:
event.target.style.display = "none";
Steven Parker
230,688 PointsSteven Parker
230,688 PointsThe "View Challenge" button seems to link to an unrelated part of the course. Can you provide a link to the part that relates to this question?