event
Change — CSS reference
MediaQueryList change fires when the match result changes, not on every resize. Use event.matches to read the new result. CSS media queries are preferable for styling alone; JS listeners are useful for associated application behavior. The initial fixture displays the current result and the supplementary harness actually crosses the threshold.
Formal Syntax & Structure
css syntaxcss
matchMedia("(min-width: 600px)").addEventListener("change", handler);Working Example
Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>change</title><style>body{margin:8px;font:16px/1.5 sans-serif}*{box-sizing:border-box}
</style><body><output id="a" aria-live="polite"></output><script>const query=matchMedia("(min-width:600px)");function render(e){document.getElementById("a").textContent=String(e.matches)}query.addEventListener("change",render);render(query);</script></body></html>