<html>
<body>
<form id="myForm" action="https://www.w3schools.com/action_page.php">
<input type="radio" name="sex" id="male" value="male">
</form>
<p>Click the button to create a LABEL element.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
var x = document.createElement("LABEL");
var t = document.createTextNode("Male");
x.setAttribute("for", "male");
x.appendChild(t);
document.getElementById("myForm").insertBefore(x,document.getElementById("male"));
}
</script>
</body>
<!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_label_create by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 27 Jan 2020 03:07:36 GMT -->
</html>