Latest web development tutorials

HTML DOM Input Button form properties

Button Object Reference Button Objects

Definition and Usage

form property returns to the form that contains the button references.

If you include the button, it returns a form object, if not included in the button, it returns null.

grammar

buttonObject.form


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support form properties


Examples

Examples

The following example returns the id of the button that contains the form:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function displayResult(){
    var x=document.getElementById("button1").form.id;
    alert(x);
}
</script>
</head>
<body>

<form id="form1">
<input type="button" onclick="displayResult()" value="显示包含按钮的表单id" id="button1">
</form>

</body>
</html>

try it"


Button Object Reference Button Objects