js 截取字串長度,截取時中文以2個位元組計算
function worldLimit(className,factLength){
$('.'+className).each(function(){
$('.'+className).each(function(){
).text();
var allLength = 0;
for (var i = 0; i if ((c >= 0x0001 && c } else {
PallLength += if(allLength > factLength){
var subContent = '';
var subLength = 00015m for (var i = 0; i var c = content.charCodeAt(i);
//單字節加1
f)) {
subLength++;
subLength += 2 ;
}
{
break;
ent = content.substring(0,factLength);
}
$(this).html($(this).html()+'......');
}
}
}
}
);