<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
Javascript code to switch between forms by pressing enter.
<script type="text/javascript">
$(document).on('keypress', 'input,select', function (e) {
if (e.which == 13) {
e.preventDefault();
var $next = $('[tabIndex=' + (+this.tabIndex + 1) + ']');
console.log($next.length);
if (!$next.length) {
$next = $('[tabIndex=1]');
}
$next.focus();
}
});
</script>
<body>
creating forms
<input type="number" name="" tabindex="1">
<input type="number" name="" tabindex="2">
<input type="number" name="" tabindex="3">
<input type="number" name="" tabindex="4">
</form>
</body>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-
q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
</html>
Ive tried many approaches and the code which is working online isnt working in my computer.