Input Color autofocus attribute

Definition and usage

autofocus Attribute sets or returns whether the color selector should automatically receive focus when the page is loaded.

This property reflects the HTML autofocus attribute.

See also:

HTML reference manual:HTML <input> autofocus-Eigenschaft

Example

Find out if the color selector will automatically receive 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 receive focus when the page is loaded.

  • true - The color selector receives focus
  • false - Default. The color selector does not receive focus

Technical details

Return value: Boolean value, if the color selector automatically receives focus when the page is loaded, it returns true, wird zurückgegeben false.

Browser-Unterstützung

Die in der Tabelle angegebenen Zahlen geben die erste vollständige Unterstützung für das Attribut durch den Browser an.

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Unterstützt 10.0 Unterstützt Unterstützt Unterstützt

Anmerkung:Der <input type="color">-Element zeigt in Internet Explorer und Safari keine Farbauswahl an.