Input Color autofocus attribute

Definition and usage

autofocus Attribute sets or returns 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-attribut

Example

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

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

Try it yourself

Syntax

Return autofocus attribute:

colorObject.autofocus

Set 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, returns if the color selector automatically gains focus when the page is loaded true, annars returneras false.

Webbläsarstöd

Numrerna i tabellen anger den första webbläsarens version som helt stöder detta attribut.

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Stöd 10.0 Stöd Stöd Stöd

Kommentar:Kommentar: <input type="color">-elementet visar ingen färgväljare i Internet Explorer och Safari.