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
精彩评论