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

Maarten van Essen
Maarten van Essen
869 Points

Select not appending

somehow my select is not appending. below is my code

var $select = $('<select></select>'); $("#menu").append($select);

Thanks.

Maarten van Essen
Maarten van Essen
869 Points

Well copying and pasting isn't going well either...but I think I've mastered the markdown now.

here is the code once more:

// create and append select to menu
var $select = $("<select></select>");
$("#menu").append($select);

What am I doing wrong?

Maarten van Essen
Maarten van Essen
869 Points

Perhaps it has to do with my browser, because I copied and pasted the code form the downloaded material, and it still doesn't work

Maarten van Essen
Maarten van Essen
869 Points

Perhaps it is appending, but I can't see it?

1 Answer

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,252 Points

Hi Maarten,

I'm guessing here but is it that you need to declare your select HTML tags in a ..html() method?

So

var $select = $("<select></select>").html();
$("#menu").append($select);
Maarten van Essen
Maarten van Essen
869 Points

Thanks. Best answer so far ;-) . However still not working. Any other ideas?