Javascript DOM HTML Input Week defaultValue Property get

Introduction

Get the default value of a week field:

var x = document.getElementById("myWeek").defaultValue;

Click the button to display the default value of the week field.

input elements with type="week" are not supported in Internet Explorer or Firefox.

View in separate window

<!DOCTYPE html>
<html>
<body>

<input type="week" id="myWeek" value="1995-W35">
<button type="button" onclick="myFunction()">Test</button>
<p id="demo"></p>

<script>
function myFunction() {//from  w ww .ja v a2 s.  co  m
  var x = document.getElementById("myWeek").defaultValue;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related