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 jQuery Basics Working with jQuery Collections Working with jQuery-Specific Selectors

Julianna Kahn
Julianna Kahn
20,702 Points

Not sure why :hidden isn't working.

I assume this would be the pseudo-class but can't check for sure without seeing CSS.

index.html
<!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>Worf</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>
app.js
const $hiddenLinks = $('li:hidden')
$hiddenLinks.show

4 Answers

Steven Parker
Steven Parker
231,236 Points

You're really close!

Anytime you call a method, you must put parentheses after the method name, even if no arguments are being passed. And while that would technically be enough to make it work, the challenge also doesn't seem to like the creation of the variable.

So try attaching the ".show()" method directly to the jQuery call with the selector in it.

Julianna Kahn
Julianna Kahn
20,702 Points

I feel silly that I missed that but it still isn't working. (And I did add the ;) I get the error "Bummer: Unexpected AST node type passed to processExpressionStatement method: VariableDeclaration."

Steven Parker
Steven Parker
231,236 Points

It sounds like you're still creating the variable, try my second suggestion. If that's not it, please show the current code.

Julianna Kahn
Julianna Kahn
20,702 Points

I guess I didn't quite understand the first part but I went back and tried it and the challenge didn't like that I didn't create the variable. Also, not quite sure of the syntax. Tried: $hiddenLinks.show('li:hidden'); Also tried adding $ either directly after show or $hiddenLinks.show($('li:hidden'));

Steven Parker
Steven Parker
231,236 Points

What I was saying is that the challenge dos not like the creation of the "$hinddenLinks" variable. So avoid the variable entirely and try attaching the ".show()" method directly to the jQuery call with the selector in it.

Julianna Kahn
Julianna Kahn
20,702 Points

I tried this: $('.character-list').show('li:hidden'); and this: $('li:hidden').show('.character-list');

I don't know why I am having such a hard time with this.

Steven Parker
Steven Parker
231,236 Points

Where did "'.character-list' come from? It wasn't part of your original solution. And the way the "show" method is being used here it doesn't need any arguments.

Julianna Kahn
Julianna Kahn
20,702 Points

I guess I was thinking that $('li:hidden') had to be selected from the "ul" with the class of .character-list. But the real problem was that I was looking at this for just too long. Took a break, looked at it again, and everything works.

Thanks for your patience.