简体   繁体   中英

jquery code when min-width set

i'm using sticky.js now i wanna use this when min-width sets to 768px in other words i don't want sticky.js works in mobiles or devices that has max-width 768px .

i use this jquery code to use sticky-js

jQuery(document).ready(function(){
    jQuery("#header").sticky({
        className : 'sticky-header' ,
        topSpacing : -45
    });
}); 

if you need more details let me know

Use a condition, and check whatever element has the min-width style set

jQuery(function($){
    var min_width = parseInt( $('body').css('min-width'), 10 );

    if ( min_width > 768 ) {
        $("#header").sticky({
            className : 'sticky-header' ,
            topSpacing : -45
        });
    }
}); 

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