简体   繁体   中英

My HTML button doesn't work. Anything wrong?

I just wanna ask if there is anything wrong with my button code.. here it is:

<button id="stop" type="Submit" class='btn btn-primary mx-sm-2 mb-1' href="/roles/meditation/meditate-timer/stop/">Stop</button>

The button should have redirected us to the url, but when i serve the file from localhost (I'm using Django), nothing happened. The button is not functional. I have inspected the element and found no error. Anyone has an idea why?
Thank you in advance!

I just wanna ask if there is anything wrong with my button code.. here it is:

<button id="stop" type="Submit" class='btn btn-primary mx-sm-2 mb-1' href="/roles/meditation/meditate-timer/stop/">Stop</button>

The button should have redirected us to the url, but when i serve the file from localhost (I'm using Django), nothing happened. The button is not functional. I have inspected the element and found no error. Anyone has an idea why?
Thank you in advance!

Buttons do not support the href attribute. You can use an <a> tag (styled as a button) instead:

<a id="stop" type="Submit" class='btn btn-primary mx-sm-2 mb-1' href="/roles/meditation/meditate-timer/stop/">Stop</a>

CSS:

a {
  padding: 10px;
  border: 1px solid blue;
  text-decoration: none;
}

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