get the html code for all radios/checkboxes within a form - Javascript jQuery

Javascript examples for jQuery:Form Checkbox

Description

get the html code for all radios/checkboxes within a form

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-1.7.js"></script> 
  <script type="text/javascript">
    $(function(){/*from  w w w  .  jav a  2s .c  om*/
var htmlarr = [];
$("input[type='radio'][name='radio123'],[type='radio'][id='radio123']").each(function () {
   htmlarr.push($(this).clone().wrap('<div>').parent().html());
})
console.log(htmlarr);
    });

      </script> 
 </head> 
 <body> 
  <input type="radio" id="radio123">  
 </body>
</html>

Related Tutorials