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 trialUnsubscribed User
3,567 PointsUncaught TypeError: $option.val is not a function
this is an error my console is showing up, i've review the video, side by side and dont see any differences...
Ali Asgar
2,112 Pointsi got the same error and after half and hour of struggling and staring the code and then going to the discussion forums , i realized that i missed the $ sign. Arghhhhhhhhhhh!!!!!
5 Answers
Unsubscribed User
3,567 PointsWHOAAAAAA MAN, thanksssssssssssssssss alot, you just saved my life, I can sleep in peace today!!!!!!!!!!!! incredible how a simple thing can ruin a whole code... Works perfectly Again, thanks a lot!!!!!!1
Jason Anello
Courses Plus Student 94,610 PointsYou're welcome. I'm glad you can get some good sleep now.
Unsubscribed User
3,567 PointsJason Anello, man, honestly don't know how to post the code... :(, have been trying to post a snapshot but dont see how...
Unsubscribed User
3,567 Points// Problem: looks gross in smaller browser and small devices width. //Solution: Make a drop down menu, for smaller devices
//Create a select and append to menu var $select = $("<select></select>"); $("#menu").append($select);
//Cycle over menu links $("#menu a").each(function(){
var $anchor = $(this);
//Create an option var $option = ("<option></option>");
//Options values are the href of the links
HERE IS WHERE JS SHOWS THE ERROR... $option.val($anchor.attr("href"));
//OPtions text are the texts of the links $option.text($anchor.text());
//Append OPtions to Select $select.append($option);
});
//Create button
Here it goes the is the code...
Jason Anello
Courses Plus Student 94,610 PointsHi Vladimir,
For posting snapshots you can check the link I gave above. It's easy to do once you check it out.
One problem I see in your code is that you're not actually creating an option element with this line:
var $option = ("");
You want to create an option
element wrapped in a jQuery object like this:
var $option = $("<option></option>");
This is done at about the 5:00 mark in the video linked to if you want to review it.
There could be other problems but fix that first and let me know where you're at.
Unsubscribed User
3,567 PointsHi there again, I've checked, and have corrected the $option (not creating and option element...) but still doesn't work, and its driving me crazy, I've checked it hundred times and dont see the mistake... here is the snapshot... By the way, thanks a lot for the quick response!!!!!
Snapshot: https://w.trhou.se/9ivrgyuu4w
Jason Anello
Courses Plus Student 94,610 PointsYou're still missing the dollar sign $
in front of
("<option></option>")
There's 2 $
symbols in the code.
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsHi Vladimir,
Can you post your code or a snapshot if you're using workspaces?
https://teamtreehouse.com/forum/workspace-snapshots