jQuery UI resizable fire window resize event

后端 未结 5 667
庸人自扰
庸人自扰 2020-12-14 07:41

I have 2 events, one to detect window resize and other to detect the resizable stop of div.

But when I resize the div, in the console detect the window resize event.

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-14 08:10

    For me, with JQuery 1.7.2 none of the solution proposed here worked. So I had to come up with a slightly different one that works on older IE browsers as well as Chrome...

    $(window).bind('resize', function(event) {
        if ($(event.target).prop("tagName") == "DIV") {return;}  // tag causing event is a div (i.e not the window)
        console.log("resize");
    });
    

    This might have to be adapted if the element resized is something else than a

提交回复
热议问题