运行 ❯
获取您
的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <form> <label id="myLabel" for="male">Male</label> <input type="radio" name="sex" id="male" value="male"><br> </form> <p>Click the "Try it" button to change the value of the for attribute of the label.</p> <button onclick="myFunction()">Try it</button> <p id="demo"></p> <script> function myFunction() { document.getElementById("myLabel").htmlFor = "newValue"; document.getElementById("demo").innerHTML = "The value of the for attribute was changed from 'male' to 'newValue'."; } </script> </body> </html>