1. Obtain a form reference
1> Obtain through direct positioning
document.getElementById();document.getElementsByName();document.getElementsByTagName();
2 > Get references through collections
document.forms[subscript]document.forms["name"]document.forms.name
3> Get " directly via name (for form only)
document.name
2. Obtain a reference to the form element
1> Get it directly
document.getElementById();document.getElementsByName();document.getElementsByTagName();
2> Get it through the collection
Form object.elements Get a collection of all elements in the form form object.elements[subscript] form object.elements["name"] form object.elements.name
3> Directly through name
Form object.name
3. Common properties and methods of form elements
1>Get the value of the form element
Form element object.value Get or set value
2>Properties
disabled Get or set whether the form control is disabled true false
form reference to a form containing this element
3>Method
blur() loses focus
focus() gets focus
The above is an example explanation of the JavaScript operation form introduced by the editor (Part 1). I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support to Wulin.com website!