I am trying to get a value from the user (taskName input),save that value in a variable and then print the value to the console when a button (taskAdd button) is clicked.However,Once I click the button I don't get the value in my browser console window.
HTML:
<label for="taskName">New Task</label>
<input type="text" id="taskName" name="task" placeholder="What is your task name?">
<input id="taskAdd" type="submit" value="Add task">
JavaScript:
function getInputValue () {
let userInput = document.getElementById("taskName").value;
console.log(userInput);
}
let addTask = document.querySelector("#taskAdd");
addTask.addEventListener("click", getInputValue());