Input Color autofocusProperty

Input Color 对象参考手册Input Color Object

Examples

Check if the color picker automatically gets focus when the page loads:

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

Try it Yourself »

Definition and Usage

The autofocus property is used to set or return whether the color picker gets focus when the page loads.

This property reflects the HTML autofocus attribute.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the autofocus property.

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

Note:Internet Explorer and Safari 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 Describes whether the color picker gets 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 when the page loads, otherwise returns false.


Related Pages

HTML Reference:HTML <input> autofocus Attribute


Input Color 对象参考手册Input Color Object Other Extensions