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!

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

Fernando Jimenez
PLUS
Fernando Jimenez
Courses Plus Student 8,023 Points

how come the .css() is not working? function not recognized?

so I first start by initializing var menu = jQuery('.hmenu_inner_holder')[0];

when I console.log menu it equals :

<div class="hmenu_inner_holder"> ...</div>

so its a bunch of html inside the <div class="hmenu_inner_holder"> div..

then I try to change the css by doing

menu.css("width":"68%"); but then I get this error:

// Uncaught SyntaxError: missing ) after argument list

I Also tried using a "," instead of ":"

then it said Uncaught TypeError: menu.css is not a function

Can you post the full code please, to get a better look at it?

1 Answer

Steven Parker
Steven Parker
224,872 Points

You were right that arguments should be separated by a comma, not a period. But when you applied the index to the jQuery function, it assigned "menu" with a plain HTML element instead of a jQuery object. And of course, plain elements don't have a ".css" method.

To select the first item as a jQuery object instead of a plain element, use the ".eq" method instead of the index:

var menu = jQuery('.hmenu_inner_holder').eq(0);