0

I am using jquery Isotope and have a series of tiles using the following layout:

<div class="element tileG g"><div class=titlePE>
    <div class="nameP"></div>
    <div class="subDefn"></div></div>
    <div class="content"></div>
</div>

content is set at height:90px. I want to be able to test if it overflows and set a visual indicator so the user knows to expand the tile. The concept I am using is on clicking button class 'letter' I briefly set content height:auto and measure its new height. Here is my code (that doesn't work :(

$(".letter").click(function () {
    $('.element').each(function(){
    h1 =  $(this).find('.content').outerHeight();
    $('.content').css( { 'height': 'auto' });
    h2 = $(this).find('.content').outerHeight();
    $('.content').css( { 'height': 90 });
    if ( h2 > h1 ) { $('.content').css( { 'background': 'white' }); }
        });
            });

All tiles end up white.

I am very open to either a new concept or some suggestions on where the above code is wrong.

Arfa
  • 105
  • 9
  • Overflows how exactly? Are you sure you can't just check if the parent elements height is below 90px ? – adeneo Sep 12 '13 at 21:12
  • overflow: as in the text content requiring more than 90px. In that if class content changed from :hidden to overflow:auto then there would be a scroll bar. "?check if the parent elements height?" Can you explain more? Parent element = class="element tileG is set overflow:hidden;height:150px – Arfa Sep 12 '13 at 22:37
  • @adeneo I had a thought that parent outerHeight might include overflow of a child. Not so. I did have (yet another) thought that as .element has overflow:hidden I can dispense with content height control and just test - as above - if h1 > 90. I will try this but I suspect there is still something not quite right with my loop. – Arfa Sep 12 '13 at 23:50
  • I see that I was approaching this like a BIG problem. After a few more coffees and a walk and such I see it is really simple. Sorry, but this has been a time-space waster. – Arfa Sep 13 '13 at 21:46

0 Answers0