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](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh07XyirpGjGcjg1CRb1XBJcRmmZvHQRFcc5j4UXoFq8BZfLBB_xg8fHBX8alq8YzIbHBAgS3bZ3eUmlGZ8DBPNqsd4mjmNBpG9R0lugOm0S2MoMZdU6u9ZTVDZjk8emmJyChPH2rezM68/s72-w400-c-h68/Bind+array+value+in+html+radio+button+using+JQuery.png)
No comments: