HTML DOM 입력 날짜 유형 속성은 입력 날짜 유형을 반환/설정합니다.
구문
다음은 구문입니다 -
- 문자열 값 반환
inputDateObject.type
- 유형 설정 문자열 값으로
inputDateObject.type = stringValue
문자열 값
여기서 "stringValue"는 다음과 같을 수 있습니다. -
| 문자열 값 | 세부정보 |
|---|---|
| 날짜 | 입력 유형이 날짜임을 정의합니다. |
| 라디오 | 입력 유형이 라디오임을 정의합니다. |
| 확인란 | 입력 유형이 체크박스임을 정의합니다. |
예시
입력 날짜 유형 속성의 예를 살펴보겠습니다. -
<!DOCTYPE html>
<html>
<head>
<title>Input Date type</title>
</head>
<body>
<form>
<div>
Calendar: <input type="date" id="dateSelect" value="2017-05-01">
</div>
</form>
<button onclick="changeType()">Change Type</button>
<div id="divDisplay"></div>
<script>
var divDisplay = document.getElementById("divDisplay");
var inputDate = document.getElementById("dateSelect");
divDisplay.textContent = 'Input type: '+ inputDate.type;
function changeType(){
if(inputDate.type === 'date'){
var currDate = inputDate.value;
inputDate.type = 'text';
inputDate.value = currDate;
}
divDisplay.textContent = 'Input type: '+ inputDate.type;
}
</script>
</body>
</html> 출력
이것은 다음과 같은 출력을 생성합니다 -
'유형 변경'을 클릭하기 전에 버튼 -

'유형 변경'을 클릭한 후 버튼 -
