最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - button href not working - Stack Overflow

programmeradmin0浏览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>
发布评论

评论列表(0)

  1. 暂无评论