JS - To prevent Page scrolling while focusing a particular portion

by barkkathulla 2013-12-21 10:48:32

How to prevent Page scrolling while focusing a particular location?

part 1:
In your html use the below as a part of a form....

<span id='errormsg' class='err'></span>

<input type="submit" class="button" id = "submit_form" value="submit" />



part 2:


$("#submit_form").click( function() {

$('#errormsg').html("<font color=red>Invalid answer.....</font><br />");

var scr = document.body.scrollTop;
window.location.href = '#';
document.body.scrollTop = scr;
window.location= '#error_msg';
return false;

});
871
like
0
dislike
0
mail
flag

You must LOGIN to add comments