IE - 单击相应标签时未选中隐藏单选按钮 [英] IE - hidden radio button not checked when the corresponding label is clicked

查看:140
本文介绍了IE - 单击相应标签时未选中隐藏单选按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在IE7中注意到一个奇怪的行为。

I just noticed a strange behaviour in IE7.

我有一个带有相关标签的单选按钮,如下:

I have radio buttons with associated labels as follows:

<input type="radio" name="filter" id="filter_1" value="Activities" checked="checked" />
<label for="filter_1">Activities</label>

<input type="radio" name="filter" id="filter_2" value="Services" />
<label for="filter_2">Services</label>

通过css使用display:none或visibility:hidden(不要求)隐藏单选按钮。

The radio button is hidden via css with display:none or visibility: hidden (don't ask)

问题是 - 当我单击IE7中的标签(尚未查看其他IE版本)时,相关的单选按钮实际上未被选中。我确认这与jquery - 标签点击事件被触发,但单选按钮单击事件不是。

The problem is - when I click the label in IE7 (haven't looked at other IE versions yet) the associated radio button is not actually checked. I confirmed this with jquery - the label click event is fired, but the radio button click event is not. A form post also confirms that the checked radio button does not change.

这在Firefox中正常工作,如果我删除隐藏单选按钮的CSS也可以正常工作。

This works correctly in firefox, and also works correctly if I remove the CSS that hides the radio buttons.

这是一个IE错误还是我缺少一些东西?

Is this an IE bug or am I missing something?

推荐答案

它可能是与 display:none - 你可能还会发现隐藏的元素不会得到他们的值提交与其余的形式。如果您有权限控制,您可以尝试将元素放置在屏幕外,而不是隐藏它们

It probably is to do with the display: none - you may also find that hidden elements don't get their values submitted with the rest of the form. If you have control over it, you may want to try positioning the elements off screen rather then hiding them.

这篇关于IE - 单击相应标签时未选中隐藏单选按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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