超出篇幅隐藏

超出字数隐藏script typetext/javascriptfunction hideNum(thisId,showLeng){var nowId document.g

超出字数隐藏
<script type="text/javascript">
function hideNum(thisId,showLeng){
       var nowId = document.getElementById(thisId);
       var nowLeng = nowId.innerHTML.length;
        if(nowLeng > showLeng){
            var nowWord = nowId.innerHTML.substr(0,showLeng)+'...';
            nowId.innerHTML = nowWord;
         }
}
</script>
      <div id="test">超过十个字我没了!~</div>
<script>
         hideNum("test",10)
</script>