I noticed that when I create a button with type=button (on an example login button) to script it with JavaScript without refreshing the page, then I can't press Enter to move forward.
Is there a workaround?
I noticed that when I create a button with type=button (on an example login button) to script it with JavaScript without refreshing the page, then I can't press Enter to move forward.
Is there a workaround?
$(document).ready(function() {
$(document).on('keypress', function(e) {
if (e.which == 13){
$('.button').trigger('click');
}
});
$('.button').on('click', function() {
alert('hi');
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text"/>
<input type="button" class="button" value="BUTTON"/>