Why does an <input type='button'> wr

2019-08-05 05:42发布

问题:

This code works in Firefox, Chrome and Safari, but is failing for me on (Windows) IE 8:

<a href='http://google.com'>
   <input type="button" name='go' value='go'>
</a>

Why? And should I just use a (clumsy) onClick event to get around it?

Grrrrr....

回答1:

You can't have a <button> inside an <a> element.

You can add some CSS to the <a> to look like a button however.

Or get around it like:

<input type="button" value="Google" onClick="javascript:location.href = 'http://google.com';" />