Input Color autofocus Attribute

Definition and usage

autofocus Attribute setting or returning whether the color selector should automatically gain focus when the page is loaded.

This property reflects the HTML autofocus attribute.

See also:

HTML Reference Manual:HTML <input> autofocus Attribute

Example

Find out if the color selector will automatically gain focus when the page is loaded:

var x = document.getElementById("myColor").autofocus;

Try it yourself

Syntax

Return the autofocus attribute:

colorObject.autofocus

Set the autofocus attribute:

colorObject.autofocus = true|false

Attribute value

Value Description
true|false

Specifies whether the color selector should gain focus when the page is loaded.

  • true - The color selector gains focus
  • false - Default. The color selector does not gain focus

Technical details

Return value: Boolean value, returned if the color selector automatically gains focus when the page is loaded true, otherwise return false.

Browser Support

The numbers in the table indicate the first browser version to fully support this attribute.

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

Note:The <input type="color"> element does not display any color selector in Internet Explorer and Safari.