HTML DOM 입력 월 자동 초점 속성은 페이지 로드 시 입력 월 필드에 초점을 맞춰야 하는지 여부를 반환하고 수정합니다.
구문
다음은 구문입니다 -
-
자동 초점 반환
object.autofocus
-
자동 초점 수정
object.autofocus = true | false
예시
HTML DOM 입력 월 자동 초점 속성의 예를 살펴보겠습니다 -
<!DOCTYPE html>
<html>
<head>
<title>HTML DOM autofocus property</title>
<style>
body{
text-align:center;
}
p{
font-size:1.5rem;
color:#ff8741;
}
input{}
button{
background-color:#db133a;
color:#fff;
padding:8px;
border:none;
width:120px;
margin:0.5rem;
border-radius:50px;
outline:none;
cursor:pointer;
}
</style>
</head>
<body>
<h1>autofocus Property Example</h1>
<p>Hi! click on disable button to disable autofocus</p>
<input type="month" autofocus value="2019-03">
<br>
<button onclick="disable()">Disable</button>
<script>
function disable() {
document.querySelector("input").autofocus = false;
}
</script>
</body>
</html> 출력
이것은 다음과 같은 출력을 생성합니다 -

월 입력 필드에서 자동 초점을 비활성화하려면 "비활성화" 버튼을 클릭하십시오.
