开发者

How do I have an input button and <a> tag?

I have this:

<a>开发者_Python百科;
Stuff stuff stuff
<input type="Submit" onclick="....">
</a>

The problem is...when I click the submit button, it goes to the instead of onclick.


Try this:

<input type="Button" onclick="....">

Use Button type instead of Submit :)

If you still want to use Submit, just place return false after your code eg:

<input type="Submit" onclick="doStuff(); return false;">


Returning false from you on click handler should prevent the default behaviour, e.g.:

<a href="index.html">
  Stuff stuff stuff
  <input type="Submit" onclick="alert('test'); return false;">
</a>


you can also make an <a> look like a button using CSS display: block or display: inline-block

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜