简体   繁体   中英

How can i use css media queries in jquery?

How can i use css media queries in the below jquery?

$('document').ready(function() {
  $('.lws_woorewards_sponsorship_submit').click(function() {
    $('.lar-history-grid-title').css('margin-top','-20px');
  });
});

Actually I want to give a margin to.lar-history-grid-title when clicking on that button for mobile only. Max width 768px;

Check with screen.width or using innerWidth.

  if(screen.width <= 768) {
     //Your code
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM