<html>
<body>
<h3>访问 LABEL 元素</h3>
<label id="myLabel" for="male">Male</label>
<input type="radio" name="sex" id="male" value="male"><br>
<p>点击按钮获取 label 绑定的元素的 id。</p>
<p id="demo"></p>
<button onclick="myFunction()">尝试一下</button>
<script>
function myFunction()
{
var x = document.getElementById("myLabel").htmlFor;
document.getElementById("demo").innerHTML = x;
};
</script>
</body>
</html>