当我更改/点击单选按钮组时,我正在使用jQuery来隐藏和显示元素.它在Firefox等浏览器中运行良好,但在IE 6和7中,仅当用户点击页面上的其他位置时才会执行操作.
详细说明,当你加载页面时,一切看起来都很好.在Firefox中,如果单击单选按钮,则会隐藏一个表行,并立即显示另一个表行.但是,在IE 6和7中,您单击单选按钮,在您单击页面上的某个位置之前不会发生任何事情.只有这样,IE才会重绘页面,隐藏并显示相关元素.
这是我正在使用的jQuery:
$(document).ready(function () {
$(".hiddenOnLoad").hide();
$("#viewByOrg").change(function () {
$(".visibleOnLoad").show();
$(".hiddenOnLoad").hide();
});
$("#viewByProduct").change(function () {
$(".visibleOnLoad").hide();
$(".hiddenOnLoad").show();
});
});
Run Code Online (Sandbox Code Playgroud)
这是它影响的XHTML的一部分.整个页面验证为XHTML 1.0 Strict.
<tr>
<td>View by:</td>
<td>
<p>
<input type="radio" name="viewBy" id="viewByOrg" value="organisation"
checked="checked" />Organisation</p>
<p>
<input type="radio" name="viewBy" id="viewByProduct" value="product" />Product</p>
</td>
</tr>
<tr class="visibleOnLoad">
<td>Organisation:</td>
<td>
<select name="organisation" id="organisation" multiple="multiple" size="10">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</select>
</td>
</tr>
<tr class="hiddenOnLoad">
<td>Product:</td>
<td>
<select name="product" id="product" multiple="multiple" size="10">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</select> …Run Code Online (Sandbox Code Playgroud)