Latest web development tutorials

HTML DOM Input Search objects

Input Search Object

Input Search object is a new HTML5.

Input Search object represents use type = "search" in the HTML <input> elements.

Access Input Search objects

You can use getElementById () function to access using type = "search" <input> element attributes:

var x = document.getElementById("mySearch"); 尝试一下

Tip: You can also form elements to access the Input Search collection of objects.

Create Input Search objects

You can use document.createElement () method to create using the type = "search" attribute of the <input> element:

var x = document.createElement("INPUT");
x.setAttribute("type", "search"); 尝试一下

Input Search object properties

Property 描述
autocomplete 设置或返回 search 字段的 autocomplete 属性值
autofocus 设置或返回 search 字段在页面加载后是否自动获取焦点
defaultValue 设置或返回 search 字段默认的值
disabled 设置或返回 search 字段是否可用
form 返回使用 search 字段的表单引用
list 返回包含了 search 字段的 datalist 引用
maxLength 设置或返回 search 字段的 maxLength 属性值
name 设置或返回 search 字段的 name 属性值
pattern 设置或返回 search 字段的 pattern 属性值
placeholder 设置或返回 search 字段的 placeholder 属性值
readOnly 设置或返回 search 字段是否只读
required 设置或返回 search 字段在表单中是否为必填字段
size 设置或返回 search 字段的 size 属性值
step 设置或返回 search 字段的 step 属性值
type 返回 search 字段的表单元素类型
value 设置或返回 search 字段的 value 属性值

Standard properties and events

Input Search Object also supports standard attributes and events .


related articles

HTML Tutorial: HTML Forms

HTML Reference Manual: HTML <the INPUT> tag

HTML Reference Manual: HTML <the INPUT> of the type attribute