0

I try to unload function if browser window less than 944px. I start to write this

$(window).resize(function() {
            if ($(window).width() >= '944') {
                        $(window).load(function() {
                            $('#slider').nivoSlider();
                        });
                    } else {
                        alert($(window).width());
                        if ($(window).width() <= '944') {
                        $(window).unload(function() {
                            $('#slider').nivoSlider();
                        });
                    }
            }
            });

but i stuck. I want if the user enters, verify resolution and if more than 944px to load jquery function, however if browser is resize or less resolution than 944px, function will be unload.

1

1 Answer 1

3

i have a different solution for your problem; you can prepare a new slider mask (just like slider but without nivoSlider functions) for <944px window width, when browser width <944px niveSlider will be hide and your mask will be seen.

check it out:

$(window).resize(function() {
    windowWidth = $(this).width();//you need to use this for changable values
    if ( windowWidth > 943) {

       $('#sliderMask').hide();
       $('#slider').show();
       $(window).load(function() {
         $('#slider').nivoSlider();
       });

    } else if ( windowWidth < 944) {

       $('#slider').hide();// hide your nivoSlider
       $('#sliderMask').show();// show your basic slider mask

    }
});

please note that: you need to use $(this) to get current value.

here is jsfiddle example for you; check the console log from your browser's developer panel

Sign up to request clarification or add additional context in comments.

2 Comments

I knew that, but I also check if you resize the browser to catch function resize () and stop the execution of nivoSlider ()
ok, than correct your jQuery with mine and use load/unload than check if code running..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.