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 3

ugh i think if forgot to put my script in the last question

so this callenge i hafta make a selector drop down and a go button to go to the page in that nav - my selector works perfectly but my button wont actually go to the selected page on the click can someone help me i feel like a goof lol

//create select and apppend
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>");


    //options value is href

$option.val($anchor.attr("href"));

    //options text is text of link
    $option.text($anchor.text());

    //append option to select
$select.append($option);  
});                        

//creat button to 
var $button = $("<button>Go</button>");
$("#menu").append($button);
//button click to go to select
$button.click(function(){


//go to selects location
 window.locaion = $select.val();
 });

1 Answer

Is your click event firing? Try console logging "button clicked" inside the click function and also the value of $select.val(); That will help you see a) if the click event is actually firing and b) what value is being piped to your location function.

Edit: Oh, you have a typo. change window.locaion to window.location.

im such a tool - ive been staring at this too long my eyess are effed lol that worked JEBUZ lol thanks