0

I'm having a problem getting javascript to execute whenever I resize the browser window. I am using the following javascript:

$(document).ready(function(){
    var heightNum = $('#work-details-info').height() + 39;
    if (($(document).width() > 767) && ($(document).width() < 900)) { 
    $('#work-details-left-cntr').css("height", (heightNum));
    }
});

It's calculating the height of a specific div. Then it is adding 39px to that height, and it sets the new height to another div. This works perfectly whenever I resize the page and then press refresh/reload. However, I want this to trigger without having to refresh/reload. How do I do that?

1 Answer 1

3

Try this:

$(window).resize(function () {
  var heightNum = $('#work-details-info').height() + 39;
  if (($(document).width() > 767) && ($(document).width() < 900)) { 
    $('#work-details-left-cntr').css("height", (heightNum));
  }
});
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.