天天看点

Input Text size 属性

Input Text size 属性

Input Text 对象

设置文本域的尺寸(以字符数计):

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

size 属性用于设置或返回文本域的 size 属性值。

size 属性设置或返回文本域的尺寸(以字符数计)。

默认值为 20。

提示: 如果要设置或返回 password 字段允许输入的字符数,请使用

maxLength 属性。

Input Text size 属性
Input Text size 属性
Input Text size 属性
Input Text size 属性
Input Text size 属性

所有主流浏览器都支持 size 属性

返回 size 属性:

textObject.size

设置 size 属性:

textObject.size=number

值<

描述

number

轨道了文本域的尺寸,以字符计。默认值为 20。

返回值:

数字,代表了文本域的尺寸,以字符计

获取文本域的尺寸:

var x = document.getElementById("myText").size;

x 输出结果为:

30

HTML 参考手册: HTML <input> size 属性

Input Text size 属性