Method 1: Use CSS to truncate the string: IE, FireFox, Opera, and Safari are all compatible
.subLongText{
width:150px;
height:24px;
overflow:hidden;
white-space:nowrap;
text- overflow:ellipsis;
text-overflow: ellipsis;/* IE/Safari */
-ms-text-overflow: ellipsis;
-o-text-overflow: ellipsis;/* Opera */
-moz-binding: url("ellipsis.xml#ellipsis");/*FireFox*/
}
Any length text
Method 2: Use js to intercept
JQUERY text interception method
< script type="text/javascript">
$.fn.substr = function(length,content){
$(this).each(function(i,item){
var val=$ (item).html();
if(!val) return;
if(val.length>length) {
val = val.substring(0,length);
val = content || "..."
$(item).html(val);
}
});
}
function subTdContent(){
$('td' ).substr(20);
}
< table style="border:1px solid #b3c0f5;" border="1">
My code: $.fn.substr = function(l,c){ $(this).each(function(i,item) |
The following two methods can solve the problem that the textarea row height automatically adapts to the height of the class content |
< ;td>The following two ways can solve the textarea row