gpt4 book ai didi

jQuery hide() 在 IE 8 上无法按预期工作

转载 作者:行者123 更新时间:2023-12-03 22:42:20 25 4
gpt4 key购买 nike

在 FF 中,这会隐藏所有 div,然后显示从“#rule_rule_type”菜单中选择的 id,这是预期的行为。在 IE 8 中,它不会隐藏所有 div id:

<script type="text/javascript" charset="utf-8">
(function($){
$('#rule_rule_type').change(function() {
$('#allowed_senders, #blocked_senders, #blocked_character_set, #custom').hide();
var id = $(this).val();
$('#' + id).show();
});
})(jQuery);
</script>

但是,这在 IE 8 中确实有效:

<script type="text/javascript" charset="utf-8">
(function($){
$('#rule_rule_type').change(function() {
$('#allowed_senders').hide();
$('#blocked_senders').hide();
$('#blocked_character_set').hide();
$('#custom').hide();
var id = $(this).val();
$('#' + id).show();
});
})(jQuery);
</script>

这很困惑。我怎样才能将其清理得更简洁,并且仍然可以在 IE 8 中工作?

谢谢,
奇普城堡
http://invoicethat.com

最佳答案

我在 IE8 和 Chrome 中运行您的示例效果很好。有什么不同吗?

<!DOCTYPE html>
<html lang="en">
<head>
<title>jQuery Sandbox</title>
</head>
<body>

<select id='rule_rule_type'>
<option value="allowed_senders">allowed_senders</option>
<option value="blocked_senders">blocked_senders</option>
<option value="blocked_character_set">blocked_character_set</option>
<option value="custom">custom</option>
</select>

<hr />

<div id="allowed_senders">#allowed_senders</div>
<div id="blocked_senders">#blocked_senders</div>
<div id="blocked_character_set">#blocked_character_set</div>
<div id="custom">#custom</div>

<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.min.js"></script>
<script type="text/javascript">

$(function () {

$('#rule_rule_type').change(function () {

$('#allowed_senders, #blocked_senders, #blocked_character_set, #custom').hide();

var id = $(this).val();
$('#' + id).show();

});

});

</script>
</body>
</html>

关于jQuery hide() 在 IE 8 上无法按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3103837/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com