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 2

Antonio Montalvo
Antonio Montalvo
10,549 Points

None of this works on my browser. Safari or Chrome. Why?

When I preview from workspaces. None of this works on the project.

//Problem is it looks bad on small devices. Phones
//Solution:To hide the text link a swap them with an apropiate navigation.

//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>");


  //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 to click to go to select's location
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 widths and show button and select
  // Also hides select and button on larger width and show 's links
//Deal selected options depending on current page

//Fixed Code Presentation

How to post Code

1 Answer

I could see some syntax errors in js file. If you fix them it should work.

//first error
 var $option = $("<option><?option>");

//fix
 var $option = $("<option></option>");

//second error 
var $button = $("<button>Go</button>")'

//fix
var $button = $("<button>Go</button>");