Javascript 扩展压缩div
当我点击它时,它可以展开div。如何添加“查看更多”链接,然后在div扩展时将其隐藏,并相对于“查看更多”链接调整行高,从而使其看起来更漂亮Javascript 扩展压缩div,javascript,jquery,Javascript,Jquery,当我点击它时,它可以展开div。如何添加“查看更多”链接,然后在div扩展时将其隐藏,并相对于“查看更多”链接调整行高,从而使其看起来更漂亮 $(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 th
$(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');
}
});
})
您可以查看jqueryslideup和slidedown
为了获得更好的效果,您可以查看jquery slideup和slidedown 要获得更好的效果,请尝试: 试试:
我把它们放在一个循环中,我该怎么办?当我点击“查看更多”时,其余的也会展开。我让它们在一个循环中,我该怎么办?当我点击“查看更多”按钮时,其他按钮也会展开。