परिचय
HTML DOM इनपुट बटन disabled प्रॉपर्टी HTML में एक इनपुट बटन के disabled एट्रिब्यूट का मान प्राप्त करती है और उसे संशोधित करती है। यह प्रॉपर्टी बटन को सक्षम या अक्षम करने के लिए उपयोगी है।
सिंटैक्स
मान प्राप्त करना
object.disabled
मान सेट करना
object.disabled = true | false
उदाहरण
नीचे दिए गए उदाहरण में, एक बटन पर क्लिक करने पर वह स्वयं अक्षम हो जाता है:
<!DOCTYPE html>
<html>
<head>
<title>HTML DOM disabled प्रॉपर्टी</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: 80%;
}
.show-message {
font-weight: bold;
font-size: 1.4rem;
color: #ffc107;
}
</style>
</head>
<body>
<h1>disabled प्रॉपर्टी उदाहरण</h1>
<input type="button" onclick="disableMe()" class="btn" value="क्लिक करके मुझे अक्षम करें">
<div class="show-message"></div>
<script>
function disableMe() {
var btn = document.querySelector(".btn");
btn.disabled = true;
document.querySelector(".show-message").innerHTML = "पहले मैं सक्षम था लेकिन अब मैं अक्षम हूँ";
}
</script>
</body>
</html>
आउटपुट
प्रारंभ में बटन सक्षम दिखेगा। "क्लिक करके मुझे अक्षम करें" बटन पर क्लिक करने के बाद, बटन अक्षम हो जाएगा और संदेश प्रदर्शित होगा।