Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> HTML

Thuộc tính disabled của <optgroup> trong HTML


Giới thiệu

Thuộc tính disabled trên <optgroup> vô hiệu hóa toàn bộ nhóm tùy chọn (option group) trong thẻ <select>. Các <option> bên trong trở nên không thể chọn, thường hiển thị xám.

Cú pháp

<optgroup disabled>

Ví dụ minh họa

<!DOCTYPE html>
<html>
<body>
  <h2>Mức nước</h2>
  <p>Mức tạp chất <meter min="0" low="50" high="95" max="100" value="85"></meter></p>
  <select>
    <optgroup label="Tỷ lệ">
      <option value="one">3:2</option>
      <option value="two">5:3</option>
    </optgroup>
    <optgroup label="Nước" disabled>
      <option value="low">2L</option>
      <option value="medium">5L</option>
      <option value="high">10L</option>
      <option value="veryhigh">20L</option>
    </optgroup>
  </select>
</body>
</html>

Kết quả hiển thị

Nhóm "Tỷ lệ" bình thường. Nhóm "Nước" bị disabled (xám, không chọn được).

<optgroup label="Nước" disabled> ... </optgroup>