MediaQueryListEvent.media

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2020.

Thuộc tính chỉ đọc media của giao diện MediaQueryListEvent là chuỗi đại diện cho một media query được tuần tự hóa.

Giá trị

Chuỗi đại diện cho một media query được tuần tự hóa.

Ví dụ

js
const mql = window.matchMedia("(max-width: 600px)");

function screenTest(e) {
  console.log(e.media); // "(max-width: 600px)"
}

mql.addEventListener("change", screenTest);

Thông số kỹ thuật

Thông số kỹ thuật
CSSOM View Module
# dom-mediaquerylistevent-media

Tương thích trình duyệt

Xem thêm