परिचय
HTML DOM इनपुट मंथ autofocus प्रॉपर्टी प्राप्त करती है और संशोधित करती है कि पेज लोड होने पर मंथ इनपुट फील्ड को फोकस मिलना चाहिए या नहीं।
सिंटैक्स
मान प्राप्त करना
object.autofocus
मान सेट करना
object.autofocus = true | false
उदाहरण
मंथ इनपुट फील्ड पर ऑटोफोकस को अक्षम करना:
<!DOCTYPE html>
<html>
<head>
<title>HTML DOM autofocus प्रॉपर्टी</title>
<style>
body { text-align: center; }
p { font-size: 1.5rem; color: #ff8741; }
input {}
button {
background-color: #db133a;
color: #fff;
padding: 8px;
border: none;
width: 120px;
margin: 0.5rem;
border-radius: 50px;
outline: none;
cursor: pointer;
}
</style>
</head>
<body>
<h1>autofocus प्रॉपर्टी उदाहरण</h1>
<p>हाय! ऑटोफोकस अक्षम करने के लिए अक्षम करें बटन पर क्लिक करें</p>
<input type="month" autofocus value="2019-03">
<br>
<button onclick="disable()">अक्षम करें</button>
<script>
function disable() {
document.querySelector("input").autofocus = false;
}
</script>
</body>
</html>
आउटपुट
पेज लोड पर मंथ इनपुट फील्ड ऑटोमेटिकली फोकस होगी। "अक्षम करें" बटन पर क्लिक करने पर ऑटोफोकस बंद हो जाएगा।