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 (2014) Creating a Mobile Drop Down Menu Perform: Part 1

Sam Gord
Sam Gord
14,084 Points

select options are not clickable like what i see at the end of the video , can you see anything wrong in my code?

select options are not clickable like what i see at the end of the video , can you see anything wrong in my code?

//Create a select and append it to the menu
var $select = $('<select></select>');
$('#menu').append($select);
// cycle over menu items and 
$('#menu a').each(function(){
  var $anchor = $(this);
  // create an option for each one of em
  var $option = $('<option></option>');
  // options value is the href of the link
  $option.val($anchor.attr('href'));
  // options text is the text of the link
  $option.text($anchor.text());
  // append option to the select
  $select.append($option);
});

i also don't get any errors in the console . idk whats the problem but when i hover over the options the background of em don't get blue like what i see at the end of the video and they seem to be unclickable!

-- U P D A T E -- now i checked again and it actually works with my up and down keys on keyboard but they are definitely unclickable! WEIRD!

1 Answer

Steven Parker
Steven Parker
231,140 Points

Without knowing what your HTML was like, I made up some that seemed to go with this code and all the items in the generated select were clickable.

For a more thorough analysis, show the rest of the code. Even better, you can share the entire project if you make a snapshot of your workspace and post the link to it here.