drop down menu js issue
Unanswered
AnaisZoub posted this in #help-forum
Im trying to create this drop down menu that allows you to add the selected value to a ul li and im not getting any errors but the function is not working. Ive set up the correct const and eventlisteners I believe but Im new to js so I could be missing something. Ive only done the first case but have 5 others to add in. I just wanted to get one working first. Thanks!
function commonTasks(e) {
switch (e.target.value) {
case "amStandUp":
const newTodo = document.createElement('li');
newTodo.textContent = 'AM Stand Up';
newTodo.classList.add("amStandUp");
todoDiv.appendChild(newTodo);
break;
default:
break;
}
}
function commonTasks(e) {
switch (e.target.value) {
case "amStandUp":
const newTodo = document.createElement('li');
newTodo.textContent = 'AM Stand Up';
newTodo.classList.add("amStandUp");
todoDiv.appendChild(newTodo);
break;
default:
break;
}
}
1 Reply
Toyger
can you share full code, from this function it doesn't clear how you are calling function, which elements are triggerring event, and what is
todoDiv is it ever defined in code or not.