简体   繁体   中英

$(window).resize not working in IE

i have a problem with $(window).resize not working in Internet Explorer. I have checked only in IE 8 for now.

Basically, i have created a function, let's call it calculations(). The function changes the width/height of some elements based on the current width of the window. So that function needs to be called both on the document ready and on every resize of the browser. But when i call the function window resize it isn't working in IE! But what is even more weird is that it works perfectly fine on document ready, just not on window resize.

Here is the code:

jQuery.noConflict();   
jQuery(document).ready(function($){ 
    calculations(); // works fine here, it does all what it should do

    $(window).resize(function(){
        calculations(); // works fine in all browsers except IE
    })

    function calculations() {
      //definition of function calculations here (i haven't pasted the exact function, all it does is change some widths and heights)
    }

});

maybe :

var jNoConflit = jQuery.noConflict();   
jNoConflit(document).ready(function(){ 
    calculations(); // works fine here, it does all what it should do

    jNoConflit(window).resize(function(){
        calculations(); // works fine in all browsers except IE
    });

    function calculations() {
        alert("toto");
    };

});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM