Javascript DOM HTML Input Week value Property get

Introduction

Get the week and year of a week field:

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

Click the button to get the week and year 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 onclick="myFunction()">Test</button>
<p id="demo"></p>

<script>
function myFunction() {//from  ww w  .  j  a  va 2 s .  co m
  var x = document.getElementById("myWeek").value;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related