张鑫旭老师原文 关于文字内容溢出用点点点(…)省略号表示
一、css方法
p{
white-space:nowrap;
text-overflow:ellipsis;
overflow:hidden;
}
二、jQuery 限制字数的方法
$(document).ready(function(){
// 限制文本字数
$("p").each(function(){\
var maxwidth = 23 ; // 文本总数
if($((this).text().length > maxwidth){
$(this).text($(this).text().substring(0,maxwidth));
$(this).html($(this).html() + "...");
}
})
})