YouTip LogoYouTip

Prop Date Autofocus

HTML DOM Input Date autofocus Property

HTML DOM Input Date autofocus Property

HTML DOM Input Date autofocus Property

-- Learning not just technology, but dreams!

JavaScript Reference

Overview

JavaScript Objects

Browser Objects

DOM Objects

HTML Objects

<input> - color

<input> - datetime

Input Date autofocus Property

Input Date Object Reference Input Date Object

Example

Check if the date field automatically gets focus after the page loads:

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

x output result:

true

Try it yourself Β»


Definition and Usage

The autofocus property sets or returns whether a date field 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 by 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 or Firefox browsers do not support the <input type="date"> element.


Syntax

Return the autofocus property:

inputdateObject.autofocus

Set the autofocus property:

inputdateObject.autofocus=true|false

Property Values

Value Description
true|false Specifies whether the date field should get focus after the page loads.
  • true - The date field gets focus.
  • false - Default. The date field does not get focus.

Technical Details

Return Value: A Boolean value. Returns true if the date field automatically gets focus after the page loads, otherwise false.

Related Pages

HTML Reference: HTML <input> autofocus Attribute


Input Date Object Reference Input Date Object

<input> - color

<input> - datetime

ByteDance Coding Plan supports mainstream large models such as Doubao, GLM, DeepSeek, Kimi, MiniMax, etc., officially supplied, stable and reliable.

iFlytek Coding Plan includes free model call quota

← Prop Date DisabledDom Obj Date β†’