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

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 90,705 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?