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 Using change()

Perfect Mobile Dropdown challenge

Not sure I understand the code challenge, given that in the perfect video the .change(); method is shown, I thought I would have to apply that onto the challenge, something like below:

$button.change(function(){ //Go to select's location window.location = $select.val(); });

However does not really seem to be what the challenge asks, can someone help please?

2 Answers

Guy Noda-Bailey
Guy Noda-Bailey
18,837 Points

The button no longer exists because in the previous challenge we deleted the code that appends the button;

$("#menu").append($button); //we deleted this append

So instead of binding the .change event to the button, we want it to call the function when the $select element has been changed;

$select.change(function(){
  //Go to select's location
  window.location = $select.val();
});

// This way, as soon as a user selects an option from
// the $select element the function runs and sends the 
// browser to the page they selected.  This eliminates 
// the need for the end user to make an extra click 
// on the "Go" button.

Amazing Guy,

Thanks for your help, you cleared up my doubt!

:)

Guy Noda-Bailey
Guy Noda-Bailey
18,837 Points

No worries. The forums are great aren't they.

Yep they are! :)