为什么< input type ='button'>包裹在< a>中标签在IE中不起作用? [英] Why does an <input type='button'> wrapped in an <a> tag not work in IE?

查看:164
本文介绍了为什么< input type ='button'>包裹在< a>中标签在IE中不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此代码适用于Firefox,Chrome和Safari,但对我来说失败了(Windows)IE 8:

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>

为什么?我应该只使用一个(笨拙的)onClick事件绕过它吗?

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

Grrrrr ....

Grrrrr....

推荐答案

您在< a> < button> $ c>元素。

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

您可以在< a> 中添加一些CSS,看起来像一个按钮但是。

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

或者像它一样绕过它:

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

这篇关于为什么&lt; input type ='button'&gt;包裹在&lt; a&gt;中标签在IE中不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆