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 trialXavi Guasch
10,882 PointsCHALLENGE: Working with JQuery specific selectors. Where am I wrong?
This is my solution. Can't figure out why it doesn't work.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Document</title>
<link rel="stylesheet" href="style.css" type="text/css" media="screen" title="no title" charset="utf-8">
</head>
<body>
<h2>Star Trek Characters</h2>
<ul class="character-list">
<li>Captain Jean Luc Picard</li>
<li>Data</li>
<li>Warf</li>
<li>Dr. Crusher</li>
</ul>
<div>I am supposed to stay hidden!</div>
<script
src="jquery-3.2.1.min.js"></script>
<script src="app.js"></script>
</body>
</html>
const $hiddenItems = $('li:hidden');
$hiddenItems.show();
4 Answers
Olga DC
16,680 PointsI think your code would work, but maybe in this challenge they want it different, without assigning the lis and divs to variables. I've done it this way, and it works:
$('li:hidden').show();
$('div:hidden').show();
Olga DC
16,680 PointsThey say there is also a div element that is hidden, so you have to show it the same way you've done with the li elements.
Jonathan Grieve
Treehouse Moderator 91,253 PointsAs a Trekkie, I'd love to think the answer is because one of the list items says "Warf" instead of "Worf" ;)
Xavi Guasch
10,882 PointsThanks for the response, but how do I add the div element? I've tried this way:
const $hiddenItems = $('li:hidden', 'div:hidden');
$hiddenItems.show();
And also this way:
const $hiddenItems = $('li:hidden');
$hiddenItems.show();
const $hiddenDiv = $('div:hidden');
$hiddenDiv.show();
Neither of them works....
Xavi Guasch
10,882 PointsYes, now it works!
Muchas gracias, Olga! :)
Olga DC
16,680 PointsΒ‘de nada! :)