I have a simple HTML form and try to get the value for email and password from it with jQuery. In result I always get empty string. Can someone please tell me what I have to change
HTML form:
<form>
<label for="email">Email</label>
<input type="email" id="email">
<label for="password">Password</label>
<input type="text" id="password">
<button id="button">Submit</button>
</form>
jQuery code :
$(function() {
var x = $("#email").val();
var y = $("#password").val();
$('#button').click(function() {
alert(x);
alert(y);
})
});