I'm trying to get the height of every h2 in a div, then if that height is higher than 21px, apply a class to that h2 or change his css.
The reason for that is that I have my project titles overlapping the tags when they're longer than a single line :
so far I've tried this :
$('.post-details h2').each(function(){
if($(this).height() > 21)
{
$(this).css({"margin-top": "315px", "line-height": "28px"});
}
});
AND this :
$('.post-details h2').each(function(){
if($(this).height() > 21)
{
$(this).addClass('margintop');
}
});
None of them work. I've tried without using each as well, didn't work because it would select all of my h2 and apply the css/class to all of them. - if you have a better solution than the ones I'm considering they're welcome as well.
Many thanks for your help!
I think this is what you are looking for
Just change it to your preferences.
https://jsfiddle.net/370mg7ak/1/