Is it possible to change a Javascript variable depending on CSS media queries? for eg. I have a variable in javascript called deviceSize
and this is set to desktop
by default. And I have 3 different media queries for Desktop Tablet and Mobile. How can I make Javascript know the media query that it is being used?
I want to do this because I want to disable certain features of my game in mobile. My game is a minesweeper game, and it has three difficulty levels. It starts with a 16x16 grid because of deviceSize
. So I want javascript to change this variable depending on the media query that CSS detects. So I set deviceSize
to mobile and start the game with a 8x8 grid.
Here is my game: https://github.com/sacredcandies/minesweeper