Not sure the best way to do this, but I am trying to build a menu with a function then to insert it into the dom with jquery. I have tried bothe the methods below to no avail. All I am getting is "undefined" where the new links should be. If anyone can tell me what I am doing wrong, or give a little hint on a better way to code this, you would save the day
//The menu function function buildMenu() { var i; for (i in menu1) { var menuItem = menu1[i]; document.write(menuItem); } } // The jquery manipulation Attempt #1 $(".MainMenu").html("<div class='MainMenuItems'>" + buildMenu() + "</ div>"); // Attempt #2 $(".MainMenu").html("<div class='MainMenuItems'><script>buildMenu();</ script></div>");