Search code examples
javascriptjqueryhtmlhref

Can I use a <button> instead of <a> to go to #location?


I have this code.

<li class="active">
    <a href="#tab-weekly" data-toggle="tab">Weekly Payment</a>
</li>
<li>
    <a href="#tab-advance" data-toggle="tab">Advance Payment</a>
</li>
<li>
    <a href="#tab-data" data-toggle="tab">Expenses</a>
</li>

My question is that can I use <button> instead of <a> to achieve this? I changed it to buttons but they are not working.


Solution

  • Yes. Use <button type="button" onclick="window.location.href='YOUR URL HERE'">Link Text</button>