HTML DOM 입력 숫자 자리 표시자 속성은 숫자 입력 필드의 자리 표시자 속성 값을 반환하고 수정합니다.
구문
다음은 구문입니다 -
-
자리 표시자 반환
object.placeholder
-
자리 표시자 수정
object.placeholder = “text”
예시
HTML DOM 입력 숫자 자리 표시자 속성의 예를 살펴보겠습니다 -
<!DOCTYPE html>
<html>
<head>
<style>
html{
height:100%;
}
body{
text-align:center;
color:#fff;
background: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%) center/cover no-repeat;
height:100%;
}
p{
font-weight:700;
font-size:1.1rem;
}
input{
display:block;
width:35%;
border:2px solid #fff;
background-color:transparent;
color:#fff;
font-weight:bold;
padding:8px;
margin:1rem auto;
}
.btn{
background:#0197F6;
border:none;
height:2rem;
border-radius:2px;
width:35%;
margin:2rem auto;
display:block;
color:#fff;
outline:none;
cursor:pointer;
}
</style>
</head>
<body>
<h1>placeholder property Demo</h1>
<p>Hi, Enter your age:</p>
<input type="number" class="numberInput" placeholder="Enter your age">
<button type="button" onclick="change()" class='btn'>Change Placeholder</button>
<script>
function change() {
var numberInput = document.querySelector(".numberInput");
numberInput.placeholder = "Please enter your age";
}
</script>
</body>
</html> 출력
이것은 다음과 같은 출력을 생성합니다 -

"자리 표시자 변경 ” 버튼을 눌러 자리 표시자의 값을 변경합니다.
