<script src="http://img.17k.com/js/jquery-latest.pack.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
jQuery.fn.numberLimit=function(){
 var self = $("[@numberLimit]");
 self.each(function(){
  var objString = $(this).text();
  var objLength = $(this).text().length;
  var num = $(this).attr("limit");
 if(objLength > num){
  objString = $(this).text(objString.substring(0,num) + "...");
  }
 })
}
$(function(){
 $("[@numberLimit]").numberLimit();
})
</script>
<div numberLimit="5">我太长了吗,怎么变成省略号了?</div>
 posted on 2008-12-12 14:38  刘卿  阅读(171)  评论(0编辑  收藏  举报