Combine onload and onresize (jQuery)

前端 未结 5 1213
失恋的感觉
失恋的感觉 2020-12-22 19:29

I want to call the function on load as well as on resize.

Is there a better way to rewrite this more compactly?

$(\'.content .right\').width($(window         


        
5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-22 20:07

    I think the best solution is just to bind it also to the load event:

    $(window).on('load resize', function () {
        $('.content .right').width( $(this).width() - 480 );
    });
    

提交回复
热议问题