คุณสมบัติ HTML DOM Textarea ที่ปิดใช้งานจะส่งคืนและแก้ไขว่าองค์ประกอบพื้นที่ข้อความในเอกสาร HTML ถูกปิดใช้งานหรือไม่
ไวยากรณ์
ต่อไปนี้เป็นไวยากรณ์ -
1. การกลับมาถูกปิดใช้งาน
object.disabled
2. ปิดการใช้งานเพิ่ม
object.disabled = true | false
ให้เราดูตัวอย่างของ 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 disabled Property Demo</h1>
<textarea placeholder="Hi! I'm placeholder text of a textarea element" rows="8" cols='20'></textarea>
<button onclick="set()" class="btn">Disable Textarea</button>
<script>
function set() {
document.querySelector("textarea").disabled = true;
}
</script>
</body>
</html> ผลลัพธ์

คลิกที่ “ปิดการใช้งาน Textarea ” เพื่อปิดการใช้งานองค์ประกอบ textarea
