简体   繁体   中英

jQuery function (Window resized)

Here is my code :

jQuery(document).ready(function (e) {

    resized();
    jQuery(window).resize(resized);

    function resized() {
        wd = parseInt(jQuery(window).width());
        if (wd >= 992) {
            var wrhei = jQuery(document).height();
            jQuery('#menu').height(wrhei);
        }
    }
});

I want to call function when I resize the page without refreshing the page just when I resize function happen

Here is the code / approach, I am using in my project and it works great. Call the $(window).resize function in the document ready event as shown below,

$(document).ready(function () {
    $(window).resize(function () {
        Resized();           
    });
});

function Resized()
{
  //your code here
}

You can try :

jQuery(window).on('resize', function(e) {
    wd = parseInt(jQuery(window).width());
    if (wd >= 992) {
        var wrhei = jQuery(document).height();
        jQuery('#menu').height(wrhei);
    }
});

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