JavaScript jQuery Basics Working with jQuery Collections Working with jQuery-Specific Selectors

Julianna Kahn
Julianna Kahn
20,699 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
174,022 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,699 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
174,022 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,699 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
174,022 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,699 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
174,022 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,699 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.