HTML DOM 입력 텍스트 비활성화 속성은 텍스트 필드를 비활성화할지 여부를 설정하거나 반환하는 데 사용됩니다. 요소가 비활성화되어야 함을 나타내는 true와 그렇지 않으면 false인 부울 값을 사용합니다. disabled 속성은 기본적으로 false로 설정됩니다. 비활성화된 요소는 기본적으로 회색으로 표시되며 클릭할 수 없습니다.
구문
다음은 −
의 구문입니다.비활성화된 속성 설정 -
textObject.disabled = true|false;
여기에서 true=텍스트 필드가 비활성화되고 false=텍스트 필드가 비활성화되지 않습니다. 기본적으로 거짓입니다.
예시
입력 텍스트 비활성화 속성에 대한 예를 살펴보겠습니다. -
<!DOCTYPE html>
<html>
<body>
<h1>Input Text disabled Property</h1>
USERNAME: <input type="text" id="TEXT1" autofocus>
<p>Disable the above text field by clicking on the DISABLE button</p>
<button type="button" onclick="disableText()">DISABLE</button>
<p id="Sample"></p>
<script>
function disableText() {
document.getElementById("TEXT1").disabled=true;
document.getElementById("Sample").innerHTML = "The text field is now disabled" ;
}
</script>
</body>
</html> 출력
이것은 다음과 같은 출력을 생성합니다 -

DISABLE 버튼을 클릭하면 텍스트 필드가 비활성화됩니다 -
