jQuery Uncaught TypeError:undefined不是函数错误

时间:2014-12-15 22:05:40

标签: jquery html css

我正在尝试在重新调整窗口大小时运行一个函数。我从某个地方获得了这个代码,并且正在尝试实现它。函数本身在页面加载时运行良好。但每次调用$(window).resize时,我都会在控制台中收到上述错误。

这是代码:

var bg = $(".mw_fsbg");
$(window).resize("resizeBackground");
function resizeBackground() {

    /* set background of fullscreen fixed div to 100% and welcome div also */
    bg.height($(window).height());
}

resizeBackground();

1 个答案:

答案 0 :(得分:0)

从参数中删除引号:

$(window).resize(resizeBackground);
相关问题