Input Checkbox type 속성은 Input Checkbox의 유형을 반환/설정합니다.
구문
다음은 구문입니다 -
- 문자열 값 반환
inputCheckboxObject.type
- 유형 설정 문자열 값으로
inputCheckboxObject.type = stringValue
문자열 값
여기서 "stringValue"는 다음과 같을 수 있습니다. -
| 문자열 값 | 세부정보 |
|---|---|
| 확인란 | 입력 유형이 확인란임을 정의합니다. |
| 라디오 | 입력 유형이 라디오임을 정의합니다. |
| 텍스트 | 입력 유형이 텍스트임을 정의합니다. |
예시
입력 확인란 유형 의 예를 살펴보겠습니다. 속성 -
<!DOCTYPE html>
<html>
<head>
<title>Type Attribute of Checkbox</title>
</head>
<body>
<form id="Form">
<div>
Other: <input id="formCheckbox" type="checkbox" name="formCheckbox">
</div>
</form>
<button onclick="changeType()">Change type of input</button>
<div id="displayDiv"></div>
<script>
var typeOfInput = document.getElementById("formCheckbox");
var displayDiv = document.getElementById("displayDiv");
displayDiv.textContent = 'Type of Input: ' + typeOfInput.type function changeType(){
if(typeOfInput.type == 'checkbox'){
typeOfInput.type = 'text' displayDiv.textContent = 'Type of Input: ' + typeOfInput.type
}
}
</script>
</body>
</html> 출력
이것은 다음과 같은 출력을 생성합니다 -
'입력 유형 변경' 버튼을 클릭하기 전에 -

'입력 유형 변경' 버튼 클릭 후 -
