MaxwellLynn
MaxwellLynn

Reputation: 968

How to stop any functionality of jquery if the browser is smaller than 900px

There is a Jquery slider that I need to disable when my browser gets to a certain width, which I can do, however I don't know how to disable the slider/jquery so it stops its functionality of sliding and instead will just show the html and css which im changing with media queries.

I'm going to use a if else statement for this but don't know what to put inside the if else statement for it to do nothing.

Thanks

Upvotes: 0

Views: 56

Answers (1)

Rich Bradshaw
Rich Bradshaw

Reputation: 72965

$(window).resize(function() {
    if ($(window).width() < 900) {
        // Do your thing
    }
}).trigger('resize');

That will call everytime the window is resized. I'm triggering it once so that if it's already smaller it will run.

Upvotes: 1

Related Questions