HTML DOM Input Week type Property

HTMLWeb DevelopmentFront End Technology

The HTML DOM Input Week type property returns/sets type of Input Week.

Syntax

Following is the syntax −

  • Returning string value
inputWeekObject.type
  • Setting type to string value
inputWeekObject.type = stringValue

String Values

Here, “stringValue” can be the following −

stringValueDetails
weekIt defines that input type is week
datetime-localIt defines that input type is datetime-local
checkboxIt defines that input type is checkbox
textIt defines that input type is text

Example

Let us see an example for Input Week type property −

 Live Demo

<!DOCTYPE html>
<html>
<head>
<title>Input Week type</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>Week-type</legend>
<label for="WeekSelect">Event:
<input type="week" id="WeekSelect">
</label>
<input type="button" onclick="getTypeOfInput()" value="What type of input?">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
   var divDisplay = document.getElementById("divDisplay");
   var inputWeek = document.getElementById("WeekSelect");
   function getTypeOfInput() {
      divDisplay.textContent = 'Type of input Expected: '+inputWeek.type;
   }
</script>
</body>
</html>

Output

This will produce the following output −

Before clicking ‘What type of input?’ button −

After clicking ‘What type of input?’ button −

raja
Published on 29-Jul-2019 08:16:19
Advertisements