Input Range autofocusProperty

Input Range 对象参考手册Input Range Object

Example

Check whether the slider control automatically gets focus after the page loads:

var x = document.getElementById("myRange").autofocus;
xThe output result is:
true

Try it Yourself »

Definition and Usage

The autofocus property is used to set or return whether the slider control automatically gets focus after the page loads.

This property reflects the HTML autofocus attribute.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the autofocus attribute

Note:Internet Explorer 9 and earlier IE versions do not support HTML <input> elements with the type="range" attribute.


Syntax

Return the autofocus property:

rangeObject.autofocus

Set the autofocus property:

rangeObject.autofocus=true|false

Property Values

Value Description
true|false Describes whether the slider control gets focus after the page loads
  • true - The slider control gets focus
  • false - Default. The slider control does not get focus

Technical Details

Return Value: A Boolean value, returning true if the slider control automatically gets focus after the page loads, otherwise returning false.


Related Pages

HTML Reference:HTML <input> autofocus Attribute


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