How do I get CSS mediaqueries to work with jQuery $(window).innerWidth()?

后端 未结 5 1382
再見小時候
再見小時候 2020-12-09 04:13

I\'m trying to let jQuery take care of a menu, while CSS does something to the window background when resizing the browser.

So jQuery does something like this:

5条回答
  •  误落风尘
    2020-12-09 04:53

    window.matchMedia is a way you can fire events when media selectors kick on or off. It's new so not widely supported, but seems pretty useful.

    "Using media queries from code" from MDN

提交回复
热议问题