Create radio button via Javascript

Description

The following code shows how to create radio button via Javascript.

Example


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.6.4.js'></script>
<script type='text/javascript'>
$(window).load(function(){<!--from  ww w. ja  v a2 s  .c o  m-->
   $('div#new').append('<form><div id=\"radio\"><input type=\"radio\" id=\"radio1\" name=\"radio\" /><label for=\"radio1\">Choice 1</label><input type=\"radio\" id=\"radio2\" name=\"radio\" /><label for=\"radio2\">Choice 2</label><input type=\"radio\" id=\"radio3\" name=\"radio\" /><label for=\"radio3\">Choice 3</label></div></form>');
});
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet"
  href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" />
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"></script>
</head>
<body>
  <div class="test">TEST</div>
  <div id="new"></div>
</body>
</html>

Click to view the demo





















Home »
  jQuery Mobile »
    Example »




Button
Button Event
Button Icon
Button Text
Checkbox
Collapsible
Date
Dialog
Event
Footer
Form
Header
Icon
Input
Layout
Listview
Listview Divider
Listview Item
Loader
mobile_settings
Navbar
Page
Page Event
Popup
Radio
Select
Slider
Switch
Textarea
Theme