javascript - Show div when radio button is activated -


this question has answer here:

i'm trying same already asked question. problem: have 40 divs shown , don't want 10 lines of code each one...

has tips give on topic? thx guys. :)

try . need replace id class.

after comment .here 2 demo demo1 , demo2 think want . showing next div selection . if want show save div.then change

var value=$(this).attr('value'); var value=$(this).attr('value')-1;

$(document).ready(function() {     $('input[type="radio"]').click(function() {         $('.show-me').hide();         var value=$(this).attr('value');         $( ".show-me:eq("+value+")" ).show();     });  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>  <form id='form-id'>      <input value='1' name='test' type='radio' />radio1      <input value='2' name='test' type='radio' />radio2      <input value='3' name='test' type='radio' />radio3      <input value='4' name='test' type='radio' />radio4      <input value='5' name='test' type='radio' />radio5<br />      <input value='6' name='test' type='radio' />radio6      <input value='7' name='test' type='radio' />radio7      <input value='8' name='test' type='radio' />radio8      <input value='9' name='test' type='radio' />radio9      <input value='10' name='test' type='radio' />radio10        </form>      <div class='show-me' style='display:none'>div 1</div>      <div class='show-me' style='display:none'>div 2</div>      <div class='show-me' style='display:none'>div 3</div>      <div class='show-me' style='display:none'>div 4</div>      <div class='show-me' style='display:none'>div 5</div>      <div class='show-me' style='display:none'>div 6</div>      <div class='show-me' style='display:none'>div 7</div>      <div class='show-me' style='display:none'>div 8</div>      <div class='show-me' style='display:none'>div 9</div>      <div class='show-me' style='display:none'>div 10</div>


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -