
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
HTML DOM Input Time defaultValue Property
The HTML DOM Input Time defaultValue property sets/returns the default value corresponding to Time Input. The value attribute changes as the user changes the time but default value does not change.
Syntax
Following is the syntax −
- Returning string value
inputTimeObject.defaultValue
- Setting defaultValue to string
inputTimeObject.defaultValue = ‘string’
Example
Let us see an example of Input Time defaultValue property −
<!DOCTYPE html> <html> <head> <title>Input Time defaultValue</title> <style> form { width:70%; margin: 0 auto; text-align: center; } * { padding: 2px; margin:5px; } input[type="button"] { border-radius: 10px; } </style> </head> <body> <form> <fieldset> <legend>Time-defaultValue</legend> <label for="TimeSelect">Meeting At: <input type="time" id="TimeSelect" value="09:30"> </label><br> <input type="button" onclick="changeMeet('Alternate')" value="Alternate Meeting Time"> <input type="button" onclick="changeMeet('Default')" value="Default Meeting Time"><br> <input type="button" onclick="confirmMeet()" value="Confirm Meeting"> <div id="divDisplay"></div> </fieldset> </form> <script> var divDisplay = document.getElementById("divDisplay"); var inputTime = document.getElementById("TimeSelect"); function changeMeet(string) { if (inputTime.disabled === false) { if(string === 'Alternate') inputTime.value = '10:30'; else inputTime.value = inputTime.defaultValue; } } function confirmMeet() { inputTime.disabled = true; divDisplay.textContent = 'Meeting fixed at : '+inputTime.value; } </script> </body> </html>
Output
This will produce the following output −
Before clicking ‘Alternate Meeting Time’ button −
Changing Time Input by clicking ‘Alternate Meeting Time’ button −
After clicking ‘Default Meeting Time’ button −
After clicking ‘Confirm Meeting’ button −
- Related Articles
- HTML DOM Input Month defaultValue Property
- HTML DOM Input Number defaultValue Property
- HTML DOM Input Color defaultValue Property
- HTML DOM Input Email defaultValue Property
- HTML DOM Input URL defaultValue Property
- HTML DOM Input Week defaultValue Property
- HTML DOM Input Password defaultValue Property
- HTML DOM Input Search defaultValue Property
- HTML DOM Input Text defaultValue Property
- HTML DOM Textarea defaultValue Property
- HTML DOM Input Time autofocus Property
- HTML DOM Input Time disabled Property
- HTML DOM Input Time form Property
- HTML DOM Input Time max Property
- HTML DOM Input Time min Property

Advertisements