我有一个包含两个组合的页面:根据第一个组合中选择的选项,显示/隐藏第二个组合。这适用于FF3.5,但不适用于IE8。在IE8中,第二个组合框会短暂显示然后消失。它在Windows XP SP3下运行。
<table width="100%">
<tr>
<td>
<table>
<tr>
<td>
New Status
</td>
<td id="ForwardLabel">
Forward to
</td>
</tr>
<tr>
<td>
<select id="ReviewStatusID" name="ReviewStatusID" style="width:200px;">
<option value="">-- select --</option>
<option value="5">In Progress</option>
<option value="4">Forwarded</option>
<option value="2">Pending</option>
<option value="3">Rejected</option>
<option value="1">Approved</option>
</select>
</td>
<td id="ForwardCombo">
<select id="ForwardToMemberID" name="ForwardToMemberID" style="width:300px;">
<option value="">-- select --</option>
<option value="1">Fred Smith</option>
</select>
</td>
</tr>
</table>
</td>
</tr>
<!-- other table elements ommitted -->
</table>
<script type="text/javascript">
$(document).ready(function() {
// hides the controls as soon as the DOM is ready
$('#ForwardLabel').hide();
$('#ForwardCombo').hide();
// if the Status box is "Forwarded" then show the "Forward to" control
$('#ReviewStatusID').change(function() {
if ($('#ReviewStatusID').val() == 4) {
$('#ForwardLabel').show(250);
$('#ForwardCombo').show(250);
} else {
$('#ForwardLabel').hide(250);
$('#ForwardCombo').hide(250);
}
});
});
</script>
答案 0 :(得分:1)
我在重新测试IE 8时遇到了完全相同的问题。
似乎在hide()或show()中设置的计时器值存在问题。
我通过将show(0)替换为show()来解决我的问题。
答案 1 :(得分:0)
它为我工作,是否有任何其他js被加载在页面上?您也可以尝试使用bind和unbind而不是更改功能。
答案 2 :(得分:0)
我通过将我需要隐藏/显示的表元素包装在div中来解决问题 即。
<td id="ForwardLabel">
Forward to
</td>
变为
<td><div id="ForwardLabel">
Forward to
</div></td>
这是有效的。感谢所有提供帮助的人:)