Input Week defaultValue Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Week


The defaultValue property sets or gets the default value of a week field.

The default value is the value specified in the HTML value attribute.

You can use defaultValue property to find out whether the week of a week field have been changed.

Set the defaultValue property with the following Values

Value Description
value Sets the default value of the week field

Return Value

A String, representing the default value of the week field

The following code shows how to change the default value of a week field:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<input type="week" id="myWeek" value="1995-W35">

<button type="button" onclick="myFunction()">Test</button>

<p id="demo"></p>

function myFunction() {/*from   www.  j  a  v a2 s  .  c  om*/
    var x = document.getElementById("myWeek");
    x.defaultValue = '2000-W1';



Related Tutorials