TextAfter that, the page should go toid , without...">

JQuery go to id (no animation)

Script adds idfor the block, gives:

<div id="some">Text</div>

After that, the page should go toid , without animation, just like we have targeting #somethe link of the current page.

How to do it?

Thank.

+5
source share
4 answers

You mean the link to the "old school" like # some

for example

<a href="#some"></a>

Done in JS using

location.href = "#some"; 
+10
source

Try the following:

 document.getElementById('some').scrollIntoView(true);
+19
source

Like this:

location.href = "#some"; 
+3
source
$('a[href^="#"]').click(function() {
$('html,body').animate({ scrollTop: $(this.hash).offset().top});
return false;
e.preventDefault();
});
+2
source

All Articles