以特定屏幕大小调用脚本

时间:2015-05-26 16:18:51

标签: javascript jquery

有关如何让以下脚本仅在> 767屏幕尺寸上工作的任何想法?

<script>
$(document).ready(function() {
    $(window).fadeThis({
        baseName: "slide-",
        speed: 500, 
        easing: "easeOutCubic",
        offset: 0, 
        reverse: false, 
        distance: 50, 
        scrolledIn: null, 
        scrolledOut: null
    });
});
</script>

1 个答案:

答案 0 :(得分:1)

使用CSS:

<link rel="stylesheet" media="screen and (min-width:767px)"  href="yourcssfilefor767.css" type="text/css">

如果你必须动态地这样做:

<script>
$(document).ready(function() {
    $(window).on("change", function(){
       if($(window).width() > 767){
         //do stuff here
       }
    });
});
</script>