HTML DOM Textarea defaultValue प्रॉपर्टी एक HTML दस्तावेज़ में टेक्स्ट क्षेत्र तत्व के डिफ़ॉल्ट मान को लौटाती है और संशोधित करती है।
सिंटैक्स
निम्नलिखित वाक्य रचना है -
<मजबूत>1. डिफ़ॉल्ट मान लौटा रहा है
object.defaultValue
<मजबूत>2. डिफ़ॉल्ट मान जोड़ना
object.defaultValue = “text”
आइए हम HTML DOM Textarea डिफ़ॉल्टवैल्यू प्रॉपर्टी का एक उदाहरण देखें:
उदाहरण
<!DOCTYPE html>
<html>
<style>
body {
color: #000;
background: lightseagreen;
height: 100vh;
}
.btn {
background: #db133a;
border: none;
height: 2rem;
border-radius: 2px;
width: 40%;
display: block;
color: #fff;
outline: none;
cursor: pointer;
}
</style>
<body>
<h1>DOM Textarea defaultValue Property Demo</h1>
<textarea rows="5" cols='20'>Hi! I'm a textarea element with some dummy text.</textarea>
<button onclick="set()" class="btn">Change Defualt Value</button>
<script>
function set() {
document.querySelector("textarea").defaultValue = "Hi! I'm default value of textarea element.";
}
</script>
</body>
</html> आउटपुट

textarea तत्व के डिफ़ॉल्ट मान को बदलने के लिए "डिफ़ॉल्ट मान बदलें" बटन पर क्लिक करें।
