[stackoverflow] show/hide dynamic content
3895867/dynamically-checking-the-value-of-a-radio-button-refactoring-question
HTML
<input type="radio" name="show_hide" value="#d1"> 1
<input type="radio" name="show_hide" value="#d2"> 2
<input type="radio" name="show_hide" value="#d3,#d4,#d5"> 3,4,5
<input type="radio" name="show_hide" value=""> None
<div id="d1">1: Lorem</div>
<div id="d2">2: Ipsum</div>
<div id="d3">3: Dolor</div>
<div id="d4">4: Sit</div>
<div id="d5">5: Amet</div>
JavaScript
var $all = $($('#show_all').val());
$('input[name=show_hide]').change(function() {
var $show = $(this.value).show();
$all.not($show).hide();
});
//initial setup:
$all.not($('input[name=show_hide]:checked').val()).hide();