CSSStyleSheet: removeRule() method
Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
Phương thức removeRule() đã lỗi thời của CSSStyleSheet loại bỏ một quy tắc khỏi đối tượng bảng kiểu. Nó có chức năng tương tự như phương thức tiêu chuẩn, được khuyến nghị deleteRule().
Note:
Đây là một phương thức legacy đã được thay thế bằng
phương thức tiêu chuẩn deleteRule(). Bạn
nên sử dụng phương thức đó thay vì phương thức này.
Cú pháp
removeRule(index)
Tham số
index-
Chỉ số trong
CSSRuleListcủa bảng kiểu cho biết quy tắc cần xóa.
Giá trị trả về
Không có (undefined).
Ví dụ
Ví dụ này xóa quy tắc đầu tiên khỏi bảng kiểu myStyles.
myStyles.removeRule(0);
Bạn có thể viết lại để sử dụng phương thức deleteRule() tiêu chuẩn rất dễ dàng:
myStyles.deleteRule(0);
Specifications
| Thông số kỹ thuật |
|---|
| CSS Object Model (CSSOM)> # dom-cssstylesheet-removerule> |