2011-10-25 71 views
1

http://jsfiddle.net/Y8MUF/擴大壓縮div

它可以擴大div,當我點擊它。如何通過添加「See More」鏈接使其看起來更好看,然後在div放大並調整相對於See More鏈接的行高時隱藏它?

$(document).ready(function(){ 
var rowsshown = 2; 
var rowheight = 1.2; // line height in 'em' 
var ht = (rowsshown * rowheight) - .5; // subtracting the .5 prevents the top of the next line from showing 
$('.info') 
    .css({'overflow':'hidden','line-height' : rowheight + 'em','height': ht + 'em' }) 
    .click(function(){ 
    if ($(this).css('height') == 'auto') { 
    $(this).css('height', ht + 'em'); 
    } else { 
    $(this).css('height','auto'); 
    } 
    }); 
}) 

回答