How to bind array value in HTML radio button using JQuery

 Hello Friends, in this article, we learn how to bind array in radio input using JQuery.


Script code:

<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

    <script type="text/javascript">

        $(document).ready(function () {

            var array  = ["NEERAJ", "AMIT", "RAM", "SANDESH", "RAJESH", "RIYA", "SONALI"];

            var htmlradio = '';

            $.each(array, function (index, value) {

                htmlradio += '<input type="radio" name="group" id="' + value + '" value="' + value + '"  /><label  for="' + value + '">' + value + '</label>';

                $("#radiogroup").html(htmlradio);

            });

        });

    </script>

HTML code:

  <fieldset style="width:600px">

        <legend>Bind array value in html radio button using JQuery

        </legend>

        <div id="radiogroup"></div>

    </fieldset>

 

Out-Put:

 


How to bind array value in HTML radio button using JQuery How to bind array value in HTML radio button using JQuery Reviewed by NEERAJ SRIVASTAVA on 3:04:00 PM Rating: 5

No comments:

Powered by Blogger.