Get the id of the form the <object> element belongs to:
var x = document.getElementById("myObject").form.id;
Click the button to display the id of the form the object element belongs to.
<!DOCTYPE html> <html> <body> <form id="form1"> An Example Form: <input type="text" name="exampleform"> </form>// w w w . j a v a2s . com <object id="myObject" data="video.mp4" width="200" height="200" name="obj1" form="form1"></object> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myObject").form.id; document.getElementById("demo").innerHTML = x; } </script> </body> </html>
The form
property sets or gets the value of the form attribute of an <object> element.
The form attribute sets one or more forms the <object> element belongs to.
Value | Description |
---|---|
form_id | Specifies the <form> element the <object> element belongs to. |
The form
property returns a String representing one or more forms the object belongs to.