Thuộc tính type của Input Week trong HTML DOM trả về/thiết lập kiểu của trường nhập tuần.
Cú pháp
Trả về giá trị chuỗi:
inputWeekObject.type
Thiết lập type thành giá trị chuỗi:
inputWeekObject.type = stringValue
Các giá trị chuỗi (stringValue)
| stringValue | Mô tả |
|---|---|
| week | Định nghĩa kiểu nhập là tuần (week) |
| datetime-local | Định nghĩa kiểu nhập là datetime-local |
| checkbox | Định nghĩa kiểu nhập là checkbox |
| text | Định nghĩa kiểu nhập là text |
Ví dụ
Ví dụ minh họa thuộc tính Input Week type:
<!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">Sự kiện: <input type="week" id="WeekSelect"> </label> <input type="button" onclick="getTypeOfInput()" value="Kiểu nhập liệu gì?"> <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>
Kết quả
Trước khi nhấn nút 'Kiểu nhập liệu gì?':

Sau khi nhấn nút 'Kiểu nhập liệu gì?':
