<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>
${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>
本文介绍了一种通过JavaScript实现的内容显示效果,该效果能够在不破坏阅读体验的前提下,根据预设长度对长文本进行截断,并以'......'形式显示超出部分。此方法适用于博客、新闻摘要等场景。
686

被折叠的 条评论
为什么被折叠?



