简体   繁体   中英

HTML anchor not working on page load

When I want to refer to some part of my webpage with anchors : " http://example.com/index.html#section_11 " it's not going there.

However, once the page has completely loaded and then I go to address bar, highlight this URL and press enter, it works!

<div class="ui-paddingbox dotted_bg" id="section_11">
some text
</div>

Anchors only go to tag, i think. Try this:

  <div class="ui-paddingbox dotted_bg">
    <a name="section_11" />
    some text
  </div>

And make sure that the element won't added after loading (eg with a jquery call)

尝试这个:

<a href="#section_11">link</a>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM