YouTip LogoYouTip

Prop Color Autofocus

HTML DOM Input Color autofocus Property

HTML DOM Input Color autofocus Property

Input Color Object Reference Input Color Object

Example

Check if the color picker automatically gains focus on page load:

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

x output will be:

true

Try it yourself Β»


Definition and Usage

The autofocus property sets or returns whether a color picker should automatically get focus when the page loads.

This property reflects the HTML autofocus attribute.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

The autofocus property is supported in all major browsers.

Note: Internet Explorer 9 and earlier IE versions, Opera 12 and earlier Opera versions do not support this property.

Note: Internet Explorer and Safari browsers do not support the <input type="color"> element.


Syntax

Return the autofocus property:

colorObject.autofocus

Set the autofocus property:

colorObject.autofocus=true|false

Property Values

Value Description
true|false Specifies whether the color picker should automatically get focus when the page loads.
  • true - The color picker gets focus
  • false - Default. The color picker does not get focus

Technical Details

Return Value: A Boolean. Returns true if the color picker automatically gets focus on page load, otherwise false.

Related Pages

HTML Reference: HTML <input> autofocus Attribute


Input Color Object Reference Input Color Object

← Prop Color DisabledDom Obj Color β†’