Computer >> कंप्यूटर ट्यूटोरियल >  >> प्रोग्रामिंग >> HTML

HTML DOM Button disabled प्रॉपर्टी


HTML DOM Button disabled प्रॉपर्टी <button> एलिमेंट के disabled एट्रिब्यूट से जुड़ी है। button disabled प्रॉपर्टी का उपयोग यह सेट या लौटाने के लिए किया जाता है कि दिया गया बटन अक्षम है या नहीं। इसका उपयोग बटन को अक्षम करने के लिए किया जाता है ताकि यूज़र निर्दिष्ट एलिमेंट के साथ अब इंटरैक्ट न कर सके। disabled प्रॉपर्टी सेट करने से वेब ब्राउज़र्स में डिफ़ॉल्ट रूप से बटन ग्रे हो जाएगा।

सिंटैक्स

निम्नलिखिक सिंटैक्स है -

disabled प्रॉपर्टी सेट करना -

buttonObject.disabled = true|false

यहां, true|false निर्दिष्ट करता है कि दिया गया इनपुट बटन अक्षम होना चाहिए या नहीं।

  • True − बटन अक्षम हो जाता है।
  • False − बटन अक्षम नहीं होगा।

आइए button disabled प्रॉपर्टी का एक उदाहरण देखें -

उदाहरण

<!DOCTYPE html> <html> <body> <button id="Button1">BUTTON</button> <p>Click the below button to disable the above button.</p> <button onclick="buttonDis()">CLICK IT</button> <p id="Sample"> <script>    function buttonDis() {       document.getElementById("Button1").disabled = true;       var x=document.getElementById("Button1").disabled;       document.getElementById("Sample").innerHTML = "Button disabled is "+x;    } </script> </body> </html>

आउटपुट

यह निम्नलिखिक आउटपुट उत्पन्न करेगा -

HTML DOM Button disabled प्रॉपर्टी

CLICK IT बटन पर क्लिक करने पर -

HTML DOM Button disabled प्रॉपर्टी

उपरोक्त उदाहरण में -

हमने id “Button1” के साथ एक बटन बनाया है और बटन डिफ़ॉल्ट रूप से सक्षम है।

<button id="Button1">BUTTON</button>

फिर हमारे पास buttonDis() मेथड को क्लिक पर निष्पादित करने के लिए CLICK IT बटन है।

<button onclick="buttonDis()">CLICK IT</button>

buttonDis() मेथड इसकी id “button1” द्वारा बटन एलिमेंट को प्राप्त करता है और इस पर disabled एट्रिब्यूट को true पर सेट करता है। बटन को अक्षम करने के बाद इसका disabled मान (true या false) वेरिएबल x को असाइन किया जाता है और id “Sample” वाले पैराग्राफ में प्रदर्शित किया जाता है

function buttonDis() {    document.getElementById("Button1").disabled = true;    var x=document.getElementById("Button1").disabled;    document.getElementById("Sample").innerHTML = "Button disabled is "+x; }

  1. HTML DOM Input Submit disabled प्रॉपर्टी HTML DOM Input Submit disabled प्रॉपर्टी

    HTML DOM Input submit disabled प्रॉपर्टी का उपयोग यह सेट या वापस करने के लिए किया जाता है कि सबमिट बटन को अक्षम किया जाना चाहिए या नहीं। यह बूलियन मानों का उपयोग करता है जिसमें true दर्शाता है कि सबमिट बटन को अक्षम किया जाना चाहिए और false अन्यथा। disabled प्रॉपर्टी डिफ़ॉल्ट रूप से false पर सेट होती

  1. HTML DOM Input Reset disabled प्रॉपर्टी HTML DOM Input Reset disabled प्रॉपर्टी

    HTML DOM Input Reset disabled प्रॉपर्टी का उपयोग यह सेट या प्राप्त करने के लिए किया जाता है कि रीसेट बटन डिसेबल होना चाहिए या नहीं। यह बूलियन मानों का उपयोग करता है, जिसमें true दर्शाता है कि रीसेट बटन डिसेबल होना चाहिए और false अन्यथा। Disabled प्रॉपर्टी डिफ़ॉल्ट रूप से false पर सेट होती है। डिसेबल

  1. HTML DOM टेक्स्टएरिया disabled प्रॉपर्टी: टेक्स्टएरिया अक्षम/सक्षम करना HTML DOM टेक्स्टएरिया disabled प्रॉपर्टी: टेक्स्टएरिया अक्षम/सक्षम करना

    HTML DOM टेक्स्टएरिया disabled प्रॉपर्टी लौटाती और संशोधित करती है कि HTML दस्तावेज़ में टेक्स्ट एरिया एलिमेंट अक्षम है या नहीं। सिंटैक्स 1. disabled प्राप्त करना: object.disabled 2. disabled सेट करना: object.disabled = true | false उदाहरण: टेक्स्टएरिया अक्षम करना <!DOCTYPE html> <html&g