In JS and HTML I am trying to make it that when a user inputs their email address and clicks a login button the JS program will alert()
the email address that they inputted.
Instead, all the program does is alert the default value, value="___@gmail.com"
, and not the value that the user inputted. I read something about getting the default value vs. the new value, but it never quite explained. Is it that .value
needs to be different?
FYI, the snippet doesn't work
function myFunction() {
var x = document.getElementById("emailData").value;
alert(x)
}
document.getElementById("loginButton").onclick = myFunction;
<ion-icon name="mail-outline"></ion-icon>
<input type="email" id="emailData" value="___@gmail.com" required>
<label for="">Email</label>
<button id="loginButton">Log in</button>