HTML DOM 입력 URL 자리 표시자 속성은 일반적으로 사용자에게 입력 텍스트의 모양에 대한 힌트를 제공하는 데 사용되는 문자열을 설정/반환합니다.
구문
다음은 구문입니다 -
- 문자열 값 반환
inputURLObject.placeholder
- 자리 표시자 설정 문자열 값으로
inputURLObject.placeholder = stringValue
예시
입력 URL 자리 표시자 속성의 예를 살펴보겠습니다. -
<!DOCTYPE html>
<html>
<head>
<title>Input URL placeholder</title>
<style>
form {
width:70%;
margin: 0 auto;
text-align: center;
}
* {
padding: 2px;
margin:5px;
}
input[type="button"] {
border-radius: 10px;
}
</style>
</head>
<body>
<form>
<fieldset>
<legend>URL-placeholder</legend>
<label for="URLSelect">URL:
<input type="url" id="URLSelect">
</label>
<input type="button" value="Get an Example" onclick="setPlaceholder()">
</fieldset>
</form>
<script>
var inputURL = document.getElementById("URLSelect");
function setPlaceholder() {
inputURL.placeholder = 'https://www.google.com';
}
</script>
</body>
</html> 출력
이것은 다음과 같은 출력을 생성합니다 -
'예시 보기'를 클릭하기 전에 버튼 -

'예시 보기'를 클릭한 후 버튼 -
