Jquery css值更改后,如何停止启动调整大小功能?

Jquery css值更改后,如何停止启动调整大小功能?,jquery,return,media-queries,window-resize,stoppropagation,Jquery,Return,Media Queries,Window Resize,Stoppropagation,在css值通过css媒体查询更改后,我试图阻止resize函数启动。这不管用。。。我希望“有一个切换”只出现一次。我怎么杀它 $(window).bind('resize', function(event) { if ($('#toggle').css('display') == 'none') { console.log("there's no toggle!"); } else { con

在css值通过css媒体查询更改后,我试图阻止resize函数启动。这不管用。。。我希望“有一个切换”只出现一次。我怎么杀它

$(window).bind('resize', function(event) {
    if ($('#toggle').css('display') == 'none')
        {
            console.log("there's no toggle!");
        }
        else {
            console.log("there IS a toggle!");
            return false; // trying to stop the function
        }
});
使用
unbind()

/


应该这样写,使用.on()和.off()


与绑定和取消绑定相比,使用on和off有什么好处?从jquery 1.7开始,.on()处理程序是首选的…最终,.bind()会像使用.live()一样被弃用(踢到路边)..on()处理程序更灵活,并同时替换.live()和.bind()。。。。您可以在此处阅读更多内容:)
$(window).unbind('resize');
else {
        console.log("there IS a toggle!");
        $(window).unbind('resize');
}
$(window).on('resize', function() {

if ($('#toggle').css('display') == 'none')
    {
        console.log("there's no toggle!");
    }
    else {
        console.log("there IS a toggle!");
        $(window).off('resize');
    }
});