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.

  • one
    And why jQuery ? The view is best rendered through styles. - user207618
  • Because the processing of certain actions and the result of their work are displayed using jquery and it is impossible to fasten css there. Therefore, I think how to do this with jquery, for sure there is some way. - Alexander Syrokvasovsky
  • I'm too lazy to translate this answer, but it may come in handy for you: stackoverflow.com/a/8876069/2902432 - Duck Learns to Hide

1 answer 1

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