HTML DOM Button form Property
Last Updated :
29 Jan, 2024
The Button form property in HTML DOM is used to return the reference of the form containing the button. It is a read-only property and returns the form object on success.Â
Syntax:
buttonObject.form
Return Value: It returns a reference to the form element containing the button. It returns NULL if the button is not in the form.Â
Example: This example shows the working of the Button form property.
HTML
<!DOCTYPE html>
< html >
< head >
< title >
HTML DOM Button form Property
</ title >
</ head >
< body style = "text-align: center;" >
< h1 >GeeksforGeeks</ h1 >
< h2 >HTML DOM Button form Property</ h2 >
< form id = "users" >
< button onclick = "myGeeks()"
id = "btn" type = "button" >
Get form ID
</ button >
</ form >
< p id = "result" ></ p >
< script >
function myGeeks() {
let x = document.getElementById("btn").form.id;
document.getElementById("result").innerHTML = x;
}
</ script >
</ body >
</ html >
|
Output:
Supported Browsers:
- Chrome 9
- Edge 16
- Firefox 4
- Opera 15
- Safari 5.1
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...