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 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! :)