HTML DOM 입력 FileUpload type 속성은 HTML 문서에서 요소의 type 속성 값을 반환합니다.
구문
다음은 구문입니다 -
object.type
예시
HTML DOM 입력 파일 업로드 유형 속성의 예를 살펴보겠습니다 -
<!DOCTYPE html>
<html>
<head>
<style>
body{
text-align:center;
background-color:#52B2CF;
color:#fff;
}
.btn{
background-color:coral;
border:none;
height:2rem;
border-radius:50px;
width:60%;
margin:1rem auto;
display:block;
color:#fff;
outline:none;
}
.show{
font-size:2rem;
color:#fff;
font-weight:bold;
}
</style>
</head>
<body>
<h1>DOM fileupload type property example</h1>
<input type = "file" class = "file-upload-btn">
<button onclick="getType()" class="btn">Click me to get value of type
property</button>
<div class="show"></div>
<script>
function getType() {
var fileBtn = document.querySelector(".file-upload-btn");
document.querySelector('.show').innerHTML = fileBtn.type;
}
</script>
</body>
</html> 출력
이것은 다음과 같은 출력을 생성합니다 -

이제 "주황색을 클릭하십시오. ” 버튼을 눌러 입력 파일 업로드 버튼의 type 속성 값을 가져옵니다.
