Latest web development tutorials

HTML DOM 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 property.


Examples

Examples

The following example returns form the button belongs id:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
</head>
<body>

<form id="form1">
<button id="button1" type="button">点我!</button>
</form>
<p>含有按钮的表单的ID:
<script>
document.write(document.getElementById("button1").form.id);
</script></p>

</body>
</html>

try it"


Button Object Reference Button Objects