คุณสมบัติประเภท HTML DOM Input Week ส่งกลับ/กำหนดประเภทของ Input Week
ไวยากรณ์
ต่อไปนี้เป็นไวยากรณ์ -
- คืนค่าสตริง
inputWeekObject.type
- การตั้งค่า ประเภท เป็นค่าสตริง
inputWeekObject.type = stringValue
ค่าสตริง
ที่นี่ “stringValue” สามารถเป็นดังต่อไปนี้ -
| stringValue | รายละเอียด |
|---|---|
| สัปดาห์ | กำหนดประเภทอินพุตคือสัปดาห์ |
| datetime-local | กำหนดประเภทอินพุตเป็น datetime-local |
| ช่องทำเครื่องหมาย | กำหนดประเภทอินพุตคือช่องทำเครื่องหมาย |
| ข้อความ | กำหนดประเภทอินพุตที่เป็นข้อความ |
ตัวอย่าง
ให้เราดูตัวอย่างสำหรับ ประเภทสัปดาห์ป้อนข้อมูล ทรัพย์สิน −
<!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> ผลลัพธ์
สิ่งนี้จะสร้างผลลัพธ์ต่อไปนี้ -
ก่อนคลิก 'ป้อนข้อมูลประเภทใด' ปุ่ม −

หลังจากคลิก 'อินพุตประเภทใด' ปุ่ม −
