用jQuery写的前台字符串切割的统一方法
方法代码:
jQuery(document).ready(function(){//截取长度公用方法jQuery.each(jQuery("[split^='length_']"),function(i){//获得截取长度var toLength = parseInt($(this).attr("split").replace("length_",""));if(jQuery.trim(this.innerHTML).length>toLength){this.title = this.innerHTML;this.innerHTML = jQuery.trim(this.innerHTML).substring(0,toLength)+"...";}});});