YouTip LogoYouTip

Dom Obj Search

HTML DOM Input Search Object

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".

Accessing 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.

Note: You can also access the Input Search object through the form's elements collection.

Creating 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.

Input Search Object Properties

Property Description
autocomplete Sets or returns the autocomplete attribute value of the search field.
autofocus Sets or returns whether the search field should automatically get 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 disabled.
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 maxLength attribute value of the search field.
name Sets or returns the name attribute value of the search field.
pattern Sets or returns the pattern attribute value of the search field.
placeholder Sets or returns the placeholder attribute value of the search field.
readOnly Sets or returns whether the search field is read-only.
required Sets or returns whether the search field must be filled out before submitting the form.
size Sets or returns the size attribute value of the search field.
step Sets or returns the step attribute value of the search field.
type Returns the form element type of the search field.
value Sets or returns the value attribute value of the search field.

Standard Properties and Events

The Input Search object also supports the standard properties and events.

← Prop Search AutofocusDom Obj Search β†’