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

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

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

सिंटैक्स

Autofocus प्रॉपर्टी सेट करने के लिए सिंटैक्स:

resetObject.autofocus = true|false

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

उदाहरण

Input Reset autofocus प्रॉपर्टी का एक उदाहरण:

<!DOCTYPE html> <html> <body> <h1> Reset Autofocus प्रॉपर्टी</h1> <form style="border:solid 2px green;padding:2px"> UserName: <input type="text" id="USR"> <br> Location: <input type="text" id="Age"> <br><br> <input type="reset" id="RESET1" autofocus> </form> <p>नीचे दिए गए बटन पर क्लिक करके रीसेट बटन की autofocus प्रॉपर्टी का मान प्राप्त करें</p> <button type="button" onclick="FocusVal()">जांचें</button> <p id="Sample"></p> <script>    function FocusVal(){       var f = document.getElementById("RESET1").autofocus;       document.getElementById("Sample").innerHTML = "रीसेट बटन की autofocus प्रॉपर्टी सेट है: "+f;    } </script> </body> </html>

आउटपुट

उपरोक्त कोड से निम्न आउटपुट प्राप्त होगा:

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

"जांचें" बटन पर क्लिक करने पर:

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

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

हमने type="reset", id="RESET1" के साथ एक <input> एलिमेंट बनाया। इस बटन पर क्लिक करने पर फॉर्म डेटा रीसेट हो जाएगा। यह बटन एक फॉर्म के अंदर है जिसमें दो टेक्स्ट फील्ड भी हैं और फॉर्म पर एक इंलाइन स्टाइल भी लागू है:

<form style="border:solid 2px green;padding:2px"> UserName: <input type="text" id="USR"> <br> Location: <input type="text" id="Age"> <br><br> <input type="reset" id="RESET1"> </form>

फिर हमने एक बटन CHECK बनाया जो यूज़र द्वारा क्लिक किए जाने पर FocusVal() मेथड को एक्जीक्यूट करेगा:

<button type="button" onclick="FocusVal()">CHECK</button>

FocusVal() मेथड getElementById() मेथड का उपयोग करके टाइप reset वाले इनपुट एलिमेंट को प्राप्त करता है और autofocus प्रॉपर्टी प्राप्त करता है। Autofocus प्रॉपर्टी रीसेट बटन के autofocus एट्रिब्यूट मान के आधार पर true और false लौटाती है। यह मान वेरिएबल f को असाइन किया जाता है और id "Sample" वाले पैराग्राफ में इसके innerHTML प्रॉपर्टी का उपयोग करके प्रदर्शित किया जाता है:

function FocusVal(){    var f = document.getElementById("RESET1").autofocus;    document.getElementById("Sample").innerHTML = "रीसेट बटन की autofocus प्रॉपर्टी सेट है: "+f; }
  1. HTML DOM Input Search autofocus प्रॉपर्टी HTML DOM Input Search autofocus प्रॉपर्टी

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

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

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

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

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