关于帖子: If Radio Button is Selected Show Div - 8 Radio Buttons / 8 Divs - Can this be simplified?
和“Rory McCrossan”的最佳答案
我尝试创建html文件“test.html”,其中包含:
<style type="text/css">
.content {display: none}
</style>
<script type="text/javascript">
$('.trigger').click(function() {
$('.content').hide();
$('.' + $(this).data('rel')).show();
});
</script>
<form id='group'>
<label>
<input type="radio" name="group1" class="sim-micro-btn trigger" data-rel="sim-micro-desktop" />
</label>
<label>
<input type="radio" name="group1" class="sim-mini-btn trigger" data-rel="sim-mini-desktop" />
</label>
<label>
<input type="radio" name="group1" class="sim-maxi-btn trigger" data-rel="sim-maxi-desktop" />
</label>
<label>
<input type="radio" name="group1" class="sim-mega-btn trigger" data-rel="sim-mega-desktop" />
</label>
</form>
<div class="billpay-internet-add-ons">
<div class="sim-micro-desktop content">sim-micro</div>
<div class="sim-mini-desktop content">sim-mini</div>
<div class="sim-maxi-desktop content">sim-maxi</div>
<div class="sim-mega-desktop content">sim-mega</div>
</div>
我可以看到单选按钮,但是当我选择任何单选按钮时,就会发生任何事情。有什么想法吗?