Search code examples
javascriptjqueryresizeonresize

Change variable on resize?


I'm trying to make the containerHeight variable change depending on the width of the browser. This is what I have so far but I'm not sure how to proceed even after reading the docs. Can someone help me out?

var containerHeight = $('#project-container').outerHeight();
window.onresize = containerHeight;
$('#project-wrapper.activated').css('max-height', containerHeight);

Solution

  • Add "px" to the end. Or 'em', whatever you're using

    $(window).on('resize', function() {
        var containerHeight = $('#project-container').outerHeight();
        $('#project-wrapper.activated').css('max-height', containerHeight + 'px');
    });