How to disable javascript for responsive design

前端 未结 6 733
北恋
北恋 2020-12-15 12:15

I have been using supersized jQuery for the slideshow background of my website. I am making the website responsive and using css media queries.

I would like to be a

6条回答
  •  無奈伤痛
    2020-12-15 12:40

    You could set a hidden div with some css rules within a media query, then check those css attributes with jQuery's css() and based on that turn your slideshow on or off. Specifically:

    @media all and (max-width: 480px) {
        #testdiv{
            display:none;
        }
    }
    

    And js:

    if($("#testdiv").css("display") == "none"){
        $.supersized({...});
    }
    

    Note that this is essentially using the Modernizr approach without actually getting the library.

提交回复
热议问题