Input Email size 属性

定义和用法

size 属性设置或返回电子邮件字段的 size 属性的值。

HTML size 属性规定电子邮件字段的宽度(以字符数计),默认值为 20。

提示:如需设置或返回密码字段中允许的最大字符数,请使用 maxLength 属性

另请参阅:

HTML 参考手册:HTML <input> size ɗanin

实例

例子 1

将电子邮件字段设置为表单提交的必填部分:

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

亲自试一试

例子 2

显示电子邮件字段的宽度(以字符数为单位):

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

亲自试一试

语法

返回 size 属性:

emailObject.size

设置 size 属性:

emailObjectsize = number

Attribute Value

Value Description
number Specifies the width of the email field in terms of the number of characters. The default value is 20.

Technical Details

Return Value: Value, represents the width of the email field in characters.

Browser Support

The numbers in the table indicate the first browser version that fully supports this property.

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support 10.0 Support Support Support