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

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -