如果字數超出 len 出現 【更多】鏈接
<script type="text/javascript">
$(function(){
var slideHeight = 75; // px
var defHeight = $('#wrap').height();
if(defHeight >= slideHeight){
$('#wrap').css('height' , slideHeight + 'px');
$('#read-more').append('<a href="#">點擊查看更多。。</a>');
$('#read-more a').click(function(){
var curHeight = $('#wrap').height();
if(curHeight == slideHeight){
$('#wrap').animate({
height: defHeight
}, "normal");
$('#read-more a').html('點擊隱藏');
$('#gradient').fadeOut();
}else{
$('#wrap').animate({
height: slideHeight
}, "normal");
$('#read-more a').html('點擊查看更多。。');
$('#gradient').fadeIn();
}
return false;
});
}
});
</script>
截取 string 的長度,多出替換爲“。。。”
if(user.signature.length>54){
user.signature =user.signature.substring(0,53)+"..."
}