Are you first timer at lazacode.org? Why not join us and start exchange your programming knowledge with everyone. Register today!

jQuery - screen size condition

0 votes
72 views
added Aug 24, 2018 in jQuery by LC Marshal Lieutenant (18,470 points)
retagged Apr 16 by LC Marshal
if ($(window).width() < 768) {
   alert('This is tab screen size');
}
else {
   alert('This is desktop size');
}

 

4 Responses

0 votes
responded Aug 29, 2018 by LC Marshal Lieutenant (18,470 points)
var alterClass = function() {
  if (($(window).width() <= 480)){
           // if its smaller, do this
          $(".sidebar").addClass('modal');
          $(".sidebar").addClass('fade');
  }else{
          // Otherwise, reverse the classes
          $(".sidebar").removeClass('modal');
          $(".sidebar").removeClass('fade');
  }
}

$(window).resize(function(){
  alterClass();
});
//use function when page loads
alterClass();

 

0 votes
responded Oct 26, 2018 by LC Marshal Lieutenant (18,470 points)
var loginHeader = $('.head-container a.login');
$(loginHeader).html('Log in to Support Centre');

//mobile screen condition
if ($(window).width() < 500) {
 $(loginHeader).html('Login');
}
else {
 $(loginHeader).html('Log in to Support Centre');
}

 

0 votes
responded Apr 16 by LC Marshal Lieutenant (18,470 points)
var skinAds = $('.skin-ads-wrapper .skin-ads'),
    fundmyhome = 'https://lazacode.org.com?trackthis',
    mainContent = $('.news-wope-theme');
// skin ads condition
if ($(skinAds).length) {
    // $('.news-wope-theme').css({'top': '300px', 'margin-bottom': '300px', 'transition': 'all .5s .2s ease-in-out'});
    if (window.outerWidth >= 1900 ) {
        $(mainContent).css({'top': '375px', 'margin-bottom': '375px', 'transition': 'all .5s .2s ease-in-out'});
    }
    else if (window.outerWidth == 1600 ) {
        $(mainContent).css({'top': '294px', 'margin-bottom': '294px', 'transition': 'all .5s .2s ease-in-out'});
    } 
    else if (window.outerWidth == 1440 ) {
        $(mainContent).css({'top': '255px', 'margin-bottom': '255px', 'transition': 'all .5s .2s ease-in-out'});
    }
    else if (window.outerWidth == 1366 ) {
        $(mainContent).css({'top': '233px', 'margin-bottom': '233px', 'transition': 'all .5s .2s ease-in-out'});
    }
    else if (window.outerWidth == 1280 ) {
        $(mainContent).css({'top': '215px', 'margin-bottom': '215px', 'transition': 'all .5s .2s ease-in-out'});
    }
    else if (window.outerWidth == 1024 ) {
        $(mainContent).css({'top': '128px', 'margin-bottom': '128px', 'transition': 'all .5s .2s ease-in-out'});
    }
    else if (window.outerWidth == 768 ) {
        $(mainContent).css({'top': '100px', 'margin-bottom': '100px', 'transition': 'all .5s .2s ease-in-out'});
    }
    else {
    //   do nothing
    }
} 
else {
    //do nothing
}

 

0 votes
responded 5 days ago by LC Marshal Lieutenant (18,470 points)
else if ($(window).width() >= 768) {
  if (window.scrollY > 8200) {
    $('#awards2019 .floating-menu').removeClass('active');
  } 
  else {
  }
}

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...