Hello! Tell me, please, how can I write such a condition on jquery, so that it would be performed only on devices with a small screen resolution, and not on the desktop. Css and media queries are not suitable, you need it on jquery. thank you in advance.
1 answer
use window.matchMedia. Sign up for window resizing and follow the conditions according to the matches.
if (window.matchMedia("screen and (min-width: 768px)").matches) { div.addClass("some-class"); } else { // ΡΠΈΡΠΈΠ½Π° ΡΠΊΡΠ°Π½Π° ΠΌΠ΅Π½ΡΡΠ΅ 768 ΠΏΠΈΠΊΡΠ΅Π»Π΅ΠΉ } - Do not use links as an answer. As a payload - maybe, but not as a complete answer. - user207618 1:22 pm
- Thanks to everyone, helped to figure it out! - Alexander Syrokvasovsky
|
jQuery? The view is best rendered through styles. - user207618