This topic contains 1 reply, has 2 voices, and was last updated by Sean Sean 2 years, 8 months ago.

How to check a radio button with jQuery ?


  • mpoirrier
    Participant

    Posts: 2
    Member Reply #1300

    Hi,

    I would like to check a radio button using jquery as

    This is to used the form_icheck.html as a template  for a project

    radio buttom definition is a follow

    <div class=”icheck-inline”>

    <label><input type=”radio” name=”radio2″ value=”1″ class=”icheck” data-radio=”iradio_square-grey”> Radio Button 1 </label>

    <label><input type=”radio” name=”radio2″ value=”2″ class=”icheck” data-radio=”iradio_square-grey”> Radio Button 2 </label>

    </div>

    I just added the value from the original template

    <script>

    jQuery(document).ready(function() {

    Metronic.init(); // init metronic core components

    Layout.init(); // init current layout

    Demo.init(); // init demo features

    FormiCheck.init(); // init page demo

    $(“input[name=radio2][value=’1′]”).prop(“checked”,true);

    });

    </script>

    I spent hours to try to check a radio button using the name and the value.

    But it’s not working at all

    Many thanks to help me

     

    • This topic was modified 2 years, 9 months ago by  mpoirrier.
    Sean
    Sean
    Keymaster

    Posts: 4206
    Support Staff Reply #1346

    Hi :),

    After changing the actual state of the control you should call the uniform API as shown below:

    $(“input[name=radio2][value=’1′]”).prop(“checked”,true);

    $.uniform.update(“input[name=radio2][value=’1′]”);

    Thanks.

You must be logged in to reply to this topic.