jQuery addClass example
Change class name on click in jQuery
by gib65
HTML
<html>
<head><title>Testing ScrollIntoView</title></head>
<body>
<form>
<input style="margin-bottom: 1000px;" type="text" /><br/>
<input style="margin-bottom: 1000px;" id="validateMe" type="text" required /><br/>
<input type="text" /><br/>
<input type="submit" />
</form>
</body>
</html>
JavaScript
$("#validateMe")[0].addEventListener("invalid", function(e) {
e.preventDefault();
this.scrollIntoView({
behavior: 'smooth',
block: 'center'
});
});
$("form").submit(function () {
console.log("submitting");
});