Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a radio button dynamically with jQuery?

I am developing a small application in which I want to create 20 radio buttons in one row.

How can I do this using jQuery?

like image 779
hardik9045 Avatar asked Apr 05 '11 11:04

hardik9045


1 Answers

I think this will serve your purpose:

for (i = 0; i < 20; i++) {
    var radioBtn = $('<input type="radio" name="rbtnCount" />');
    radioBtn.appendTo('#target');
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="target"></div>
like image 129
Deviprasad Das Avatar answered Nov 15 '22 19:11

Deviprasad Das