Input Email autocomplete 属性

定义和用法

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

启用自动完成后,浏览器会根据用户之前输入的值自动完成值。

提示:在某些浏览器中,您可能需要激活自动完成功能才能使其正常工作(请在浏览器菜单中的“首选项”下查看)。

另请参阅:

HTML 参考手册:Sifat autocomplete <input> HTML

实例

例子 1

将电子邮件字段中的自动完成设置为关闭:

document.getElementById("myEmail").autocomplete = "off";

亲自试一试

例子 2

获取自动完成的状态:

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

亲自试一试

语法

返回 autocomplete 属性:

emailObject.autocomplete

设置 autocomplete 属性:

emailObject.autocomplete = "on|off"

属性值

Description
on Default. Browsers will auto-complete values based on the user's previous inputs.
off The user must enter a value in each text field every time they use it. Browsers will not auto-complete entries.

Technical Details

Return Value: String value, indicating the state of auto-complete.

Browser Support

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

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