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!

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 3

You can remove the button?

This one button was not very friendly to the user, you can cut it and still work?

2 Answers

Kevin Powell
Kevin Powell
9,028 Points

It took me a bit of digging, but it was worth it, because I agree 100%, having a "go" button makes for some horrible usability.

I removed all the code for my button, since we're getting rid of it anyway, and added this in at the end instead.

$select.change( function () {
  $('select option:selected').each( function() {
    window.location = $select.val();

I'm still learning too, but from what I understand, what this does is looks for a change to happen to my select menu. When a change does happen, it runs a function.

The only thing here I'm not sure about if is .each is the right thing to use. It's going to grab the value of each selected option, and then use that to assign the window location... I figure this is fine, since I can only have one selected item at a time anyway.

Kevin Powell
Kevin Powell
9,028 Points

Hah, go figure this is the next lesson.... I got it sort of right, but over complicated it... the code I put there is a bit redundant.

I really did not know haha, thank you!