I have two checkboxes
ABC XYZ
when ABC is checked, I show abc content div and when XYZ is checked, I show xyz div content
everything works fine, only when I click on the ABC and XYZ radio buttons, suppose that if the ABC radio button is selected by default, the abc content div is not displayed only when clicked, I get its contents
My requirement is that when the radio switch is checked, I have to get the hidden content of this selected switch without clicking
can someone help me achieve this
http://jsfiddle.net/Qac6J/497/
HTML
<form id='group'> <div> <label> <input type="radio" name="group1" class="trigger" data-rel="abc" checked />ABC </label> <span class="abc content"> <label> <span>I belong to ABC</span> <input type="button" value="ABC"/> </label> </span> </div> <br> <div> <label> <input type="radio" name="group1" class="trigger" data-rel="xyz"/>XYZ </label> <span class="xyz content"> <label> <span>I belong to XYZ</span> <input type="button" value="XYZ"/> </label> </span> </div> </form>
CSS
.content { display: none; }
JQuery
$('.trigger').change(function() { $('.content').hide(); $('.' + $(this).data('rel')).show(); });
source share