Thuộc tính disabled của Link trong HTML DOM thiết lập/trả về việc phần tử <link> có được kích hoạt hay vô hiệu hóa.
Cú pháp
Trả về giá trị boolean - true/false:
linkObject.disabled
Thiết lập disabled thành booleanValue:
linkObject.disabled = booleanValue
Các giá trị Boolean
| booleanValue | Mô tả |
|---|---|
| true | Định nghĩa rằng <link> bị vô hiệu hóa. |
| false | Định nghĩa rằng <link> không bị vô hiệu hóa (giá trị mặc định). |
Ví dụ
Ví dụ minh họa thuộc tính Link disabled:
<!DOCTYPE html> <html> <head> <title>Link Disabled</title> <link id="extStyle" rel="stylesheet" type="text/css" href="style.css"> </head> <body> <form> <fieldset> <legend>Link-disabled</legend> <label for="WeekSelect">Tuần mục tiêu doanh số: <input type="week" id="WeekSelect" value="2020-W13" disabled> </label> <input type="button" onclick="enableWeekInput()" value="Thay đổi tuần mục tiêu doanh số"> <input type="button" onclick="beautify()" value="Vô hiệu hóa định dạng"> <div id="divDisplay"></div> </fieldset> </form> <script> var divDisplay = document.getElementById("divDisplay"); var inputWeek = document.getElementById("WeekSelect"); var extStyle = document.getElementById("extStyle"); divDisplay.textContent = 'Week Input disabled: '+inputWeek.disabled; function enableWeekInput() { inputWeek.disabled = false; divDisplay.textContent = 'Week Input disabled: '+inputWeek.disabled; } function beautify(){ extStyle.disabled = true; } </script> </body> </html>
Trong ví dụ trên 'style.css' chứa:
form { width:70%; margin: 0 auto; text-align: center; } * { padding: 2px; margin:5px; } input[type="button"] { border-radius: 10px; }
Kết quả
Trước khi nhấn nút 'Vô hiệu hóa định dạng':

Sau khi nhấn nút 'Vô hiệu hóa định dạng':
