我的代码在Mozilla和Chrome中运行完美,但在IE8中却没有,当我在IE中选择一个单选按钮时,它会显示其他单选按钮的其他选项,
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="jquery.chained.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<link rel="stylesheet" href="style.css" />
<script type="text/javascript" src="infratool.js"></script>
<script>
$(function() {
$("#submit").hide();
$("#Category").change(function() {
window.location = $(this).val().split(" ")[0];
if(loc)
window.location.href = loc;
})
});
</script>
<table width="392" border="0">
<td colspan="2" align="center"><form id="form1" name="form1" method="post" action="">
<tr>
<td align="center">
<label><input name="Radio1" type="radio" id="TestA" value="TestA" onclick="showSelect();" />TestA</label>
<label><input name="Radio1" type="radio" id="TestB" value="TestB" onclick="showSelect();" />TestB</label>
</td>
</tr>
</form>
<div id="div-id" align="center"><select name="Category" id="Category" class="hide">
<option value=" TestA TestB" selected="selected">--</option>
<option value="TestA1.php TestA">TestA1</option>
<option value="TestA2.php TestA">TestA2</option>
<option value="TestA3.php TestA">TestA3</option>
<option value="TestA4.php TestA">TestA4</option>
<option value="TestA5.php TestA">TestA5</option>
<option value="TestB1.php TestB">TestB1</option>
<option value="TestB2.php TestB">TestB2</option>
<option value="TestB3.php TestB">TestB3</option>
<option value="TestB4.php TestB">TestB4</option>
<option value="TestB5.php TestB">TestB5</option>
<option value="TestB6.php TestB">TestB6</option>
</select><input type="submit" value="Go" id="submit"/>
</div>
</table>
这是其他已经使用的java脚本
//单击单选按钮后显示选择选项:
function showSelect() {
var select = document.getElementById('Category');
select.className = 'show';
}
//选择选项,将链接与类
分开$(function(){
var select = $('#Category'),
options = select.find('option');
$('[type="radio"]').click(function(){
var visibleItems = options.filter('[value*="' + $(this).val() + '"]').show();
options.not(visibleItems).hide();
if(visibleItems.length > 0)
{
select.val(visibleItems.eq(0).val());
}
});
});
$(function() {
$("#submit").hide();
$("#Category").change(function() {
window.location = $(this).val().split(" ")[0];
if(loc)
window.location.href = loc;
})
});
这是Firefox和IE8之间的屏幕截图