When I write similar code:
if (window.matchMedia('(min-width: 761px)').matches) { }
Some changes in brackets only occur when the page loads, and already when the size of the loaded page changes, nothing changes. I decided to take the window size using the resize
function like this:
$(window).resize(function () { var widthWind = $(this).width(); if (widthWind <= 750) {}});
Tell me, am I on the right track or is there a better alternative? After all, the resize function is called many, many times.
resize
event handler is optimized (there are no heaps of meaningless and merciless "hard" operations with each call of the handler), then this is quite a normal approach. - RegentsetInterval
) check the width and perform the appropriate actions. - Regent