javascript - button href not working - Stack Overflow

admin2025-04-20  0

<a href="signUp.html"><button type="submit" class="btn btn-primary submitSignUp" >Sign Up</button></a>

Why does this not work? I have a different page called signUp and on-click of the sign-up button, I want it to go to the signUp page.

<a href="signUp.html"><button type="submit" class="btn btn-primary submitSignUp" >Sign Up</button></a>

Why does this not work? I have a different page called signUp and on-click of the sign-up button, I want it to go to the signUp page.

Share Improve this question asked Apr 8, 2017 at 22:31 UZAIR VAWDAUZAIR VAWDA 131 silver badge4 bronze badges 6
  • what error are you seeing? – hackerrdave Commented Apr 8, 2017 at 22:32
  • If you want your a tag to look like a button you must use CSS. a tag like button with CSS more ways to do it – Memristor Commented Apr 8, 2017 at 22:38
  • Look the following link: a tag like button – Memristor Commented Apr 8, 2017 at 22:39
  • Look the following link: a tag like button – Memristor Commented Apr 8, 2017 at 22:40
  • Give a try to the following link: a tag like button – Memristor Commented Apr 8, 2017 at 22:42
 |  Show 1 more ment

2 Answers 2

Reset to default 6

You should not place <button> inside <a> element as <button> consumes mouse events preventing <a> element click generation.

So try just this

<a href="signUp.html" class="btn btn-primary submitSignUp">Sign Up</a>

to have the same result I would suggest you to change your code to this:

<a class="btn btn-primary submitSignUp" href="signUp.html">Sign Up</a>
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1745105834a285284.html

最新回复(0)