Is there a way to get a <button> element to link to a location without wrapping it in an <a

后端 未结 8 1959
礼貌的吻别
礼貌的吻别 2020-12-02 06:49

Just wondering if there is a way to get a HTML

相关标签:
8条回答
  • 2020-12-02 07:31

    Here's a solution which will work even when JavaScript is disabled:

    <form action="login.html">
        <button type="submit">Login</button>
    </form>
    

    The trick is to surround the button with its own <form> tag.

    I personally prefer the <button> tag, but you can do it with <input> as well:

    <form action="login.html">
        <input type="submit" value="Login"/>
    </form>
    
    0 讨论(0)
  • 2020-12-02 07:37
    <form action="portfolio.html">
     <button type="link" class="btn btn-primary btn-lg">View Work</button>
    </form>
    

    I just figured this out, and it links perfectly to another page without having my default link settings over ride my button classes! :)

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