Skip to content Skip to sidebar Skip to footer

Windows.resize Function Issue

Here is my code $(document).ready(function(){ $(window).resize(function() { if ($(window).width() > 980) { $('.info-container a').toggle(function() {

Solution 1:

It is because your functions are in $(window).resize(); function. If you want for it to work, you need to launch at click event and resize event.

You can achieve this by wrapping your functions separately, and launching them at document.click and at window.resize.

$(document).ready(function(){
    var hide = function(){
        if ($(window).width() > 980) {
            $('.info-container a').toggle(function() {
                $(this)
                    .closest('li')
                    .find('.work-info')
                    .fadeIn();
                returnfalse;
            }, function() {
                $(this)
                    .closest('li')
                    .find('.work-info')
                    .fadeOut();
                returnfalse;
            });
        }
        else {
            $('.info-container a').unbind('click'); 
        }
    };
    $(document).click(hide);
    $(window).resize(hide);
)};

Post a Comment for "Windows.resize Function Issue"