html - javascript window.location id - Stack Overflow

I want to make the browser to scroll the div's id<div id="test">lol<div> S

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 0
Add a ment  | 

1 Answer 1

Reset to default 7

Scroll to the element:

document.querySelector('#test').scrollIntoView();

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744064853a4552454.html

相关推荐

  • html - javascript window.location id - Stack Overflow

    I want to make the browser to scroll the div's id<div id="test">lol<div> S

    9天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信