js截取字符长度

<div style="width:450px;height:10px;" id="repastInfo${rowcount}">
${entityObject.content}
</div>
<script type="text/javascript">
var detailInfo = document.getElementById('repastInfo${rowcount}').innerHTML;
if(detailInfo.length>100){
document.getElementById('repastInfo${rowcount}').innerHTML = detailInfo.substring(0, 100) + '  ......';
}else{
document.getElementById('repastInfo${rowcount}').innerHTML = detailInfo.substring(0, 100);
}
</script>  

你可能感兴趣的:(js)