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 Perfect

Krishan Wanarajan
Krishan Wanarajan
10,939 Points

Another Solution for Perfection Stage

In the mobile drop down lesson in the jQuery Basics Course, Andrew uses .change() to bind a listener to the select object. I tried to solve this problem on my own before watching the rest of the video and instead i used the following code and got a similar result...

$select.click(function() { window.location = $select.val();


is this okay? if not can someone please explain why?

1 Answer

Samuel Webb
Samuel Webb
25,370 Points

.click() reloads the page immediately when you click on the dropdown. You have to do some hackey hold the mouse button down to be able to select another page. And the goal of this is for mobile. So it would probably be fairly difficult, if not impossible, for someone to change the page their on.

.change() is a method specifically for performing an action once the value of an input, textarea or select element changes. So nothing happens until you pick one of the other pages.

.click() is a no-go for this.