Why Doesn't Page Anchor Work in Ruby On Rails?

前端 未结 1 1131
一整个雨季
一整个雨季 2021-01-29 02:59

So I have links that have an href value to load ajax and an onclick value to link to the top of the page. When I click the links both the ajax content loads and the url show a r

相关标签:
1条回答
  • 2021-01-29 03:14

    You use the attribute href to point to another anchor (which may defined either by the name or id attribute.

    For example:

    <h3><a name="menu">Menu</a></h3>
    <ul>
    <li><a href="#a001">Jump to a001</a></li>
    <li><a href="#a002">Jump to a002</a></li>
    <li><a href="#a003">Jump to a003</a></li>
    </ul>
    
    <h3><a name="a001">a001</a></h3>
    <p>paragraph text ...</p>
    
    <h3><a name="a002">a002</a></h3>
    <p>paragraph text ...</p>
    
    <h3><a name="a003">a003</a></h3>
    <p>paragraph text ...</p>
    
    <hr>
    
    <p><a href="#menu">Jump to Menu</a></p>
    

    To note, you can also use id instead of name like so...

    <a href="#a001">Jump to a001</a>
    
    ...
    
    <h3 id="a001">a001</h3>
    

    Read more about it here

    0 讨论(0)
提交回复
热议问题