Skip to content

Commit

Permalink
Add note about parens in matchMedia
Browse files Browse the repository at this point in the history
I was bitten by this and didn't find an explicit callout to help developers who might have been in my situation and could not understand why their code wouldn't work.
  • Loading branch information
chriskirknielsen authored Jan 1, 2025
1 parent 68e1dfc commit 1570119
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions files/en-us/web/api/window/matchmedia/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ matchMedia(mediaQueryString)

- `mediaQueryString`
- : A string specifying the media query to parse into a {{domxref("MediaQueryList")}}.

> [!NOTE]
> Each `mediaQueryString` condition must be wrapped in parentheses, for example: `matchMedia('(min-width: 600px)')` will work, whereas `matchMedia('min-width: 600px')` will not!

This comment has been minimized.

Copy link
@chriskirknielsen

chriskirknielsen Jan 1, 2025

Author Contributor

Oh… maybe this should be max-width instead for consistency with the later example on the page?

### Return value

Expand Down

0 comments on commit 1570119

Please sign in to comment.