Radio form 属性

定义和用法
form 属性可返回对包含该按钮的表单的引用。
若成功,该属性返回一个表单对象。
语法
radioObject.form
浏览器支持
所有主要浏览器都支持 form 属性
实例
下面的例子将返回该单选按钮所属的表单的 id:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>蜜蜂教程(mifengjc.com)</title> <script> function displayResult() { var x = document.getElementById("red").form.id; alert(x); } </script> </head> <body> <form id="form1"> 你更喜欢哪种颜色?<br> <input type="radio" name="colors" id="red">红色<br> <input type="radio" name="colors" id="blue">蓝色<br> <input type="radio" name="colors" id="green">绿色 </form> <button type="button" onclick="displayResult()">显示所属的表单id</button> </body> </html>
