<html>
<body>
<h3>A demonstration of how to access a LABEL element</h3>
<label id="myLabel" for="male">Male</label>
<input type="radio" name="sex" id="male" value="male"><br>
<p>Click the button to get the id of the element the label is bound to.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myLabel").htmlFor;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
<!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_label_get by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 27 Jan 2020 03:07:36 GMT -->
</html>