I have a hash hyperlink that is used to show specific jquery based on the hash given.
The problem is that the browser automatically scrolls to the DOM element that has the class or id...how can we stop this?
I have a hash hyperlink that is used to show specific jquery based on the hash given.
The problem is that the browser automatically scrolls to the DOM element that has the class or id...how can we stop this?
Or call .preventDefault()
in the click event of the link
$("a").click(function(e) {
e.preventDefault()
});
For that, you should use:
preventDefault();
The event.preventDefault() method stops the default action of an element from happening. For example: Prevent a submit button from submitting a form Prevent a link from following the URL
Find more about it @ w3schools : event.preventDefault()
Usage:
$("a").click(function(event){
event.preventDefault();
});