HTML DOM 입력 버튼 유형 속성은 입력 버튼의 유형, 즉 "버튼", "제출" 또는 "재설정" 유형인지 여부를 반환합니다.
구문
다음은 구문입니다 -
object.type
예시
입력 버튼 유형 속성의 예를 살펴보겠습니다 -
<!DOCTYPE html>
<html>
<head>
<title>HTML DOM type Property</title>
<style>
body{
text-align:center;
}
.btn{
display:block;
margin:1rem auto;
background-color:#db133a;
color:#fff;
border:1px solid #db133a;
padding:0.5rem;
border-radius:50px;
width:40%;
}
.show-type{
font-weight:bold;
font-size:1.4rem;
color:#ffc107;
}
</style>
</head>
<body>
<h1>type Property Example</h1>
<input type = "submit" onclick = "getType()" class = "btn" value = "Click me to know about my type">
<div class="show-type"></div>
<script>
function getType() {
var btnType = document.querySelector(".btn").type;
document.querySelector(".show-type").innerHTML = btnType;
}
</script>
</body>
</html> 출력
이것은 다음과 같은 출력을 생성합니다 -

"내 유형에 대해 알고 싶으면 클릭하세요. ” 버튼을 누르면 입력 버튼의 종류가 표시됩니다.
