$(function(){ var maxNum=100; var txtNum=$("span"); if(txtNum.text().length>=maxNum){ txtNum.html(txtNum.text().substring(0,maxNum)+"...") } })