jQuery - Execute scripts based on screen size

前端 未结 4 1479

Is it possible to only run certain jQuery scripts if the screen/device size is above xxx pixels wide?

So, for example, I only want to run a slideshow when people are

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-04 15:35

    If you want to check width size after windows is resized then:

    $(window).resize(function() {
        if( $(this).width() > width ) {
            // code
        }
    });
    

提交回复
热议问题