Thuộc tính value của Input Week trong HTML DOM trả về một chuỗi nếu thuộc tính value được định nghĩa cho trường nhập tuần. Người dùng cũng có thể thiết lập nó thành một chuỗi mới.
Cú pháp
Trả về giá trị chuỗi:
inputWeekObject.value
Thiết lập thuộc tính value thành giá trị chuỗi:
inputWeekObject.value = 'String'
Ví dụ
Ví dụ minh họa thuộc tính Input Week value:
<!DOCTYPE html> <html> <head> <title>Input Week value</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-value</legend> <label for="WeekSelect">Tuần thi cử: <input type="week" id="WeekSelect" value="2021-W35"> </label> <input type="button" onclick="updateValue()" value="Hoãn thi cử"> <div id="divDisplay"></div> </fieldset> </form> <script> var divDisplay = document.getElementById("divDisplay"); var inputWeek = document.getElementById("WeekSelect"); function updateValue() { inputWeek.value = '2021-W36'; divDisplay.textContent = 'New Examination Week: '+inputWeek.value.split('-W')[1]+' ,'+inputWeek.value.split('-W')[0]; } </script> </body> </html>
Kết quả
Trước khi nhấn nút 'Hoãn thi cử':

Sau khi nhấn nút 'Hoãn thi cử':
