Reputation: 272014
I have this:
<a>
Stuff stuff stuff
<input type="Submit" onclick="....">
</a>
The problem is...when I click the submit button, it goes to the instead of onclick.
Upvotes: 0
Views: 75
Reputation: 16926
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>
Upvotes: 1
Reputation: 705
you can also make an <a>
look like a button using CSS display: block
or display: inline-block
Upvotes: 0
Reputation: 382796
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;">
Upvotes: 2