Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript jQuery Basics (2014) Creating a Mobile Drop Down Menu Perform: Part 2

Ashton Morlote
Ashton Morlote
5,517 Points

jQuery drop down menu script is not running

I do not know why my script isn't running...

Once I figure out how to post a picture of my code I will.

//Problem: It looks bad in smaller browser width
//solution: To hide the text links and swap them out with better nav

//create a select and append to #menuvar 
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>");

  //option's value is the href
  $option.val($anchor.attr("href"));
  //option's text is the text of link
  $option.text($anchor.text());
  //append option to select
  $select.append($option);
 });
//create button 
var $button = $("<button>Go</button>");
$("#menu").append($button);
//bind click to button
$button.click(function(){
  //Go to select's location
  window.location = $select.val();
});

//modify css to hide links on small resolution and show button
//also hides select and button on larger width
//deal with selected options depending on current page

Can you post a snapshot of your workspace? http://www.teamtreehouse.com/forum/workspace-snapshots

Ashton Morlote
Ashton Morlote
5,517 Points

Nevermind. It started working now. there must have been a glitch or something in the workspace.

Thank you Marcus Parsons for showing me how to share a snapshot though! very much appreciated.

Oh okay awesome! You're welcome, Ashton. They are neat aren't they? :P