jQuery - screen size function with width() and outerWidth

0 votes
168 views
added Jul 9, 2019 in jQuery by LC Marshal Captain (25,790 points)
$(skinAds).each(function () {
    // if($(this).css('display') == 'none' || $(this).attr('style', '')){ 
    if($(this).css('display') == 'none'){ 
        console.log('skin ads - none');
        // $(this).hide();
        $(mainContent).css({'margin-top': '20px'});
        $(newsWrapr).css({'background': '#eee'});
    }
    else { 
        console.log('skin ads - show');
        $(this).show();
        $(this).css({'cursor': 'pointer'});
        $(newsWrapr).css({'background': 'none'});
        if (window.outerWidth > 1500 ) {
            $(mainContent).css({'top': '294px', 'margin-bottom': '20px', 'transition': 'all .5s .2s ease-in-out'});
        } 
        else if (window.outerWidth == 1440 || window.outerWidth == 1366 || window.outerWidth == 1280  ) {
            $(mainContent).css({'top': '260px', 'margin-bottom': '20px', 'transition': 'all .5s .2s ease-in-out'});
        }
        else if (window.outerWidth == 1024 ) {
            $(mainContent).css({'top': '197px', 'margin-bottom': '20px', 'transition': 'all .5s .2s ease-in-out'});
        }
        else if (window.outerWidth == 768 ) {
            $(mainContent).css({'top': '147px', 'margin-bottom': '20px', 'transition': 'all .5s .2s ease-in-out'});
        }
        else {
        //   do nothing
        }           
    } 
}) 

 

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