javascript - Dynamic radio button value 1 checked by default -
i use code display radio buttons, code , values loaded dynamically, cannot add checked html.
the differences between radio buttons values.
is there way let value 1 selected default?
code:
<div class="input-box"> <strong><?php echo $this->__('would recommend product friend?') ?></strong> <?php foreach ( $this->getoptions() $option ): ?> <label class="recommend"> <input type="radio" name="recommend" id="recommend_field" class="radio-gender" value="<?php echo $option['value'] ?>"<?php if ($option['value'] == $value) echo ' checked="checked"' ?>><?php echo $this->__($option['label']) ?></input> </label> <?php endforeach ?> </div>
please try bellow code select first radio button on page load
jquery(document).ready(function(){ jquery("input:radio[name=recommend]:first").attr('checked', true); })
here working demo http://jsfiddle.net/patelmit69/j25w4f7z/1/
Comments
Post a Comment