I've got an unordered list with between 1 and 3 list items in it. The unordered list is (unfortunately) inside of a fixed-height div with overflow: hidden.
<div id="container">
<ul id="tweets">
<li>
Lorem ipsum dolor sit amet, consectetur
adipiscing elit. Etiam est nisi, congue
id pulvinar eget.
</li>
<li>
Donec nisi dolor, molestie quis varius
a, dictum vel nunc. Morbi odio lorem,
viverra eu semper eu.
</li>
<li>
Mollis ac lorem. Aenean consequat
interdum mi, nec vestibulum metus mollis
non. Curabitur sed.
</li>
</ul>
</div>
If there are 3 tweets, the line-height needs to be no more than 1em to completely fit in the container. If there are less than three tweets, the line-height can be up to 1.5em to fit with the rest of the site's design.
I'm trying to do some jQuery magic to update the line-height dynamically.
var tweet_len = $("#tweets > li").size();
if (tweet_len == 0) {
// append a msg telling user there's no tweets
// (this message looks like a tweet and has line-height: 1.5em)
} else if (tweet_len > 0 && tweet_len < 3) {
$("#tweets li").each(function(){
$(this).css("line-height: 1.5em");
});
}
I tried using the code above (lines 6-8) but it's not working. (I don't think I fully have an understanding of how to use .each().)
What code should I use on lines 6-8 to update the line-height to 1.5em?