我有选择框,当选项更改时,它显示另一个选择框,它工作正常,但我希望有单选按钮显示而不是选择框。有人可以帮助我吗?
.sub{display:none;}
<script type="text/javascript">
var $sub = $('select.sub');
$('select').first().change(function () {
$sub.hide();
if (this.selectedIndex > 0)
$sub.eq(this.selectedIndex - 1).show();
}).change();
</script>
<select><--!main select box--!>
<option value="">select</option>
<option> one</option>
<option> two </option>
</select>
<select class="sub">
<option> one 1</option>
<option> one 2</option
</select>
<select class="sub">
<option> two 1</option>
<option> two 2</option>
</select>
这是我需要的,而不是上面两个选择框......
<div class="sub">
<input type="radio">one 1
<input type="radio">one 2
</div>
<div class="sub">
<input type="radio">two 1
<input type="radio">two 2
</div>
答案 0 :(得分:0)
如果这个你想要的东西?
<select>
<option value="">select</option>
<option value="sub1"> one</option>
<option value="sub2"> two </option>
</select>
<div class="sub sub1">
<input type="radio">one 1
<input type="radio">one 2
</div>
<div class="sub sub2">
<input type="radio">two 1
<input type="radio">two 2
</div>
$('.sub').hide();
$('select').on('change', function(){
$('.' + this.value).show();
});