Answer the question
In order to leave comments, you need to log in
How to undo anchor move?
There is an anchor. It is necessary that when you click on the corresponding link, the hash is added to the address bar, and the physical scroll is not carried out. Here is what I found on the Internet and put together into one. Works with bugs. Is there a more general solution?
$('a[href^="#img"]').bind('click.smoothscroll',function (e) {
e.preventDefault();
var target = this.hash,
$target = $(target);
$('html, body').stop().animate({
'scrollTop': window.pageYOffset});
window.location.hash = target;
});
Answer the question
In order to leave comments, you need to log in
$('a[href^="#img"]').on("click.smoothscroll", function(e) {
e.preventDefault();
location.hash = this.hash;
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question