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

2019-08-05 05:06发布

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条回答
家丑人穷心不美
2楼-- · 2019-08-05 05:38

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';" />
查看更多
登录 后发表回答