超過一定字數 現實爲 “更多”

如果字數超出 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)+"..."

                        }


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章