关于发布: 如果选择单选按钮显示 Div - 8 Radio Buttons / 8 Divs - 这可以简化吗?
以及“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>
我可以看到单选按钮,但是当我选择任何按钮时,什么都不会发生。任何想法?