Thuộc tính readonly của phần tử
Tuy nhiên, khách truy cập có thể sao chép nội dung đó.
Sau đây là cú pháp -
<textarea readonly>
Bây giờ chúng ta hãy xem một ví dụ để triển khai thuộc tính chỉ đọc của phần tử
Ví dụ
<!DOCTYPE html> <html> <body> <h2>Interview Questions</h2> <p>Q1</p> <textarea rows="6" cols="70" placeholder="Why do you want go for the Editor Job Profile? (100 words)"> </textarea> <p>Q2</p> <textarea rows="6" cols="70" placeholder="Do you have any previous publishing experience? (100 words)"> </textarea> <p>Guidelines to appear for interview:</p> <textarea rows="6" cols="70" readonly> The interviewee should reach at 10AM with the certificates. </textarea> </body> </html>
Đầu ra
Trong ví dụ trên, chúng ta có 3 textarea -
<p>Q1</p> <textarea rows="6" cols="70" placeholder="Why do you want go for the Editor Job Profile? (100 words)"> </textarea> <p>Q2</p> <textarea rows="6" cols="70" placeholder="Do you have any previous publishing experience? (100 words)"> </textarea> <p>Guidelines to appear for interview:</p> <textarea rows="6" cols="70" readonly> The interviewee should reach at 10AM with the certificates. </textarea>
Một trong những vùng văn bản này được đặt là chỉ đọc, do đó người dùng sẽ không thể thêm bất kỳ văn bản nào vào đó -
<textarea rows="6" cols="70" readonly> The interviewee should reach at 10AM with the certificates. </textarea>