Is there a way to avoid scrolling page up on clicking a simple link such as the one given below:
<a href="#">Click Me</a>
Is there a way to avoid scrolling page up on clicking a simple link such as the one given below:
<a href="#">Click Me</a>
Try this one:
HTML
<div>Test</div>
<a href="javascript:void(0);">Click me</a>
CSS
div{
height: 1000px;
}
The div
is only for demonstration.
jsfiddle
You can prevent the default action in a JavaScript event handler with Event.preventDefault() like this:
$('#link').click(function(e){
e.preventDefault();
});
(Assuming the link has the id link
You said you use jQuery, so I used jQuery syntax here)
Try the following one:
<a href="#!"> Click Me </a>