I'm trying to have a button that submits a text input, and have that input show as an alert. Here's my code so far (which shows an alert with "undefined"):
<p class="text-right">
<input id="input" type="text" placeholder= "Your Name">
<button id="submit" type="submit"> Submit</button>
</p>
And my Javascript code:
var input = document.getElementById("input").value;
var submit = document.getElementById("submit");
submit.addEventListener("click", function1);
function function1() {
alert(input.value);
}
element.value.valuedoesn't exist.alert(input). Don't redefinesubmit