HTML DOM Input Search Object
Input Search Object
The Input Search object is new in HTML5.
The Input Search object represents an HTML <input> element with type="search".
Access an Input Search Object
You can use the getElementById() function to access an <input> element with type="search":
var x = document.getElementById("mySearch");
Try it Yourself
Tip:You can also use the form'selementscollection to access the Input Search object.
Create an Input Search Object
You can use the document.createElement() method to create an <input> element with type="search":
var x = document.createElement("INPUT");
x.setAttribute("type", "search"); Try it Yourself
x.setAttribute("type", "search"); Try it Yourself
Input Search Object Properties
| Property | Description |
|---|---|
| autocomplete | Sets or returns the value of the autocomplete attribute of the search field |
| autofocus | Sets or returns whether the search field automatically gets focus when the page loads |
| defaultValue | Sets or returns the default value of the search field |
| disabled | Sets or returns whether the search field is enabled |
| form | Returns a reference to the form that contains the search field |
| list | Returns a reference to the datalist that contains the search field |
| maxLength | Sets or returns the value of the maxLength attribute of the search field |
| name | Sets or returns the value of the name attribute of the search field |
| pattern | Sets or returns the value of the pattern attribute of the search field |
| placeholder | Sets or returns the value of the placeholder attribute of the search field |
| readOnly | Sets or returns whether the search field is read-only |
| required | Sets or returns whether the search field is a required field in the form |
| size | Sets or returns the value of the size attribute of the search field |
| step | Sets or returns the value of the step attribute of the search field |
| type | Returns the type of form element of the search field |
| value | Sets or returns the value of the value attribute of the search field |
Standard Properties and Events
The Input Search object also supports standardpropertiesandevents。
Related Articles
HTML Tutorial:HTML Forms
HTML Reference:HTML <input> Tag
HTML Reference:HTML <input> type Attribute
Other Extensions