I'm trying to create an unordered list menu but can't get the onclick to call the proper function. How do I pass the object's keys through the onclick function?
function ulMenu(menuList) {
for (var keys in menuList) {
var li = document.createElement("li");
var textNode = document.createTextNode(keys);
li.appendChild(textNode);
li.onclick = function() { ?keys? };
ul.appendChild(li);
}
var element = document.getElementsByTagName("body")[0];
element.appendChild(ul);
}
window.onload = function() {
ulMenu({Register: Register,"Sign In": Login});
}
function Login() {
alert("Login Function");
}
function Register() {
alert("Register Function");
}