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

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


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

सिंटैक्स

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

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

buttonObject.autofocus = true|false

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

  • True − इनपुट बटन को फोकस मिलता है
  • False − इनपुट बटन को फोकस नहीं मिलता।

उदाहरण

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

<!DOCTYPE html> <html> <body> <button type="button" id="MyButton" autofocus>BUTTON</button> <p>Click the below button to know if the input button above automatically gets the focus on page load or not</p> <button onclick="buttonFocus()">CLICK IT</button> <p id="Sample"></p> <script>    function buttonFocus() {       var x = document.getElementById("MyButton").autofocus;       if(x==true)          document.getElementById("Sample").innerHTML="The input button does get focus on page load";       else          document.getElementById("Sample").innerHTML="The input button does not get focus on       page load";    } </script> </body> </html>

आउटपुट

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

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

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

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

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

हमारे पास id “MyButton” वाला एक बटन है और autofocus प्रॉपर्टी सक्षम है -

<button type="button" id="MyButton" autofocus>BUTTON</button>

फिर हमारे पास buttonFocus() फ़ंक्शन को निष्पादित करने के लिए CLICK IT बटन है -

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

buttonFocus() फ़ंक्शन getElementById() मेथड का उपयोग करके बटन एलिमेंट को प्राप्त करता है और इसका autofocus मान प्राप्त करता है, जो बूलियन है और इसे वेरिएबल x को असाइन करता है। कंडीशनल स्टेटमेंट्स का उपयोग करके हम जांचते हैं कि autofocus मान true है या false और इससे जुड़े id “Sample” वाले <p> एलिमेंट में उपयुक्त टेक्स्ट प्रदर्शित करते हैं।

function buttonFocus() {    var x = document.getElementById("MyButton").autofocus;    if(x==true)       document.getElementById("Sample").innerHTML="The input button does get focus on page load";    else       document.getElementById("Sample").innerHTML="The input button does not get focus on page load"; }

  1. HTML DOM Input Password autofocus प्रॉपर्टी HTML DOM Input Password autofocus प्रॉपर्टी

    HTML DOM input Password autofocus प्रॉपर्टी HTML <input> तत्व के autofocus attribute से जुड़ी होती है। यह प्रॉपर्टी सेट करने या लौटाने के लिए उपयोग की जाती है कि पेज लोड होने पर इनपुट पासवर्ड फील्ड को ऑटोमैटिकली फोकस किया जाना चाहिए या नहीं। सिंटैक्स autofocus प्रॉपर्टी सेट करने के लिए सिंटैक

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

    HTML DOM Input Reset autofocus प्रॉपर्टी HTML <input> एलिमेंट के autofocus एट्रिब्यूट से जुड़ी होती है। यह प्रॉपर्टी यह सेट या प्राप्त करने के लिए उपयोग की जाती है कि रीसेट बटन को पेज लोड होने पर ऑटोमैटिकली फोकस मिलना चाहिए या नहीं। सिंटैक्स Autofocus प्रॉपर्टी सेट करने के लिए सिंटैक्स: resetO

  1. HTML DOM टेक्स्टएरिया autofocus प्रॉपर्टी: ऑटो फोकस नियंत्रित करना HTML DOM टेक्स्टएरिया autofocus प्रॉपर्टी: ऑटो फोकस नियंत्रित करना

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