I have an element that needs to change height depending on the height of its child p tag:
<div id="eventpg" class="bg-pink linkbox">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec</p>
</div>
I've achived the desired change by adding a class if the paragraph is over a certain height:
var divheight = $("#eventpg p").height();
if ( divheight > 173) {
$("#eventpg").addClass("height535");
}
Which adds this class this class:
. height535{height:535px;}
This works fine in most instances but if the user rotates their device from portrait to landscape the added class still remains and the page has to be reloaded to remove it.
How do I achieve the height change 'on the fly' as it were? So if the browser window changes causing the paragraph to change height the container changes to reflect this?
Thanks