I want to make the browser to scroll the div's id
<div id="test">
lol
</div>
So I use this code
window.location = "#test";
but my url now is like this
http://locahost/index.html#test
Is it possible to delete "#test" but go to that ?
I want to make the browser to scroll the div's id
<div id="test">
lol
</div>
So I use this code
window.location = "#test";
but my url now is like this
http://locahost/index.html#test
Is it possible to delete "#test" but go to that ?
Share Improve this question asked Jul 5, 2013 at 4:49 user1128331user1128331 7274 gold badges10 silver badges20 bronze badges 01 Answer
Reset to default 7Scroll to the element:
document.querySelector('#test').scrollIntoView();