2

I have develop some html page. I want to fit side menu when change page div height

<div>  <!-- menu div-->
</div> 
<div>  <!-- content div-->
</div>

When change content div height, want to change same height in menu div. When show hidden field change content div height, I want to adjust menu div height in same height. I looking for answer in jquery or JavaScript.

4
  • $('div').height(); Commented Apr 8, 2016 at 13:14
  • If you want to work with specific divs you will need to apply ID's to them. You can use pseudo-elements but it's not a good practice for this case. Commented Apr 8, 2016 at 13:19
  • take a look at this Equal height for two divs Commented Apr 8, 2016 at 13:21
  • jsfiddle.net/vtowh2ce/3 Commented Apr 8, 2016 at 13:29

2 Answers 2

2

See about https://api.jquery.com/resize/ and http://api.jquery.com/height/

$('div').height();

or

$('div').resize();
Sign up to request clarification or add additional context in comments.

Comments

1

You can use bind/trigger for that:

$('#content-div').bind('heightChange', function(event, newHeight){
  $('#main-div').height(newHeight);
});

and trigger event on div height change:

var newHeight = 200;
$('#content-div').css('height', newHeight);
$("#content-div").trigger('heightChange', newHeight);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.