javascript - foreach radio button show more info -


i trying make each radio button, when clicked on show div more infos clicked title, when radio button clicked show info radio button , hide other 1 clicked on:

html:

<input type="radio" id="1" /> <div class="event1">  content.. </div>  <input type="radio" id="2" /> <div class="event2">  content.. </div>  <input type="radio" id="3" /> <div class="event3">  content.. </div> 

jquery:

var = 1; while(i < 10) { $('.event' + i).hide();     $("#" + i).click(function() {         $('.event' + i).show();     }); i++; } 

html

<input type="radio" name="radio" id="1" /> <div class="event">  content.. 1 </div>  <input type="radio" name="radio" id="2" /> <div class="event">  content.. 2 </div>  <input type="radio" name="radio" id="3" /> <div class="event">  content.. 3 </div> 

js

$('input[name=radio]').click(function() {     $('.event').hide();     $(this).next('.event').show(); }); 

css

.event {     display: none; } 

fiddle http://jsfiddle.net/ukn6d/


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -