早上来了,突然要我弄个超过多少字就隐藏,网上找了下,觉的都不是很合适,没办法自己写了个,扔上来备份,嘿嘿!~
这是一个链子,超过十个字我没了,嘿嘿!~
<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>