Input Search sizeProperty

Input Search 对象参考手册Input Search Object

Examples

Change the length of the search field:

document.getElementById("mySearch").size = "50";

Try it Yourself »

Definition and Usage

The size property is used to set or return the value of the size attribute of the search field.

The size property describes the length (in characters) of the search field.

The default value is 20.

Tip:If you need to set the maximum number of characters allowed in the search field, use themaxLengthproperty.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the size property.


Syntax

Return the size property:

searchObject.size

Set the size property:

searchObject.size=number

Property Values

Value Description
number Describes the length of the search field, in characters. The default value is 20.

Technical Details

Return Value: A number representing the length of the search field, in characters.


More Examples

Example

Display the length of the search field (in characters):

var x = document.getElementById("mySearch").size;
xThe output result is:
35

Try it Yourself »


Related Pages

HTML Reference:HTML <input> size attribute


Input Search 对象参考手册Input Search Object Other Extensions