Home  >  Article  >  Web Front-end  >  HTML长文本截取含有HTML代码同样适用的两种方法_javascript技巧

HTML长文本截取含有HTML代码同样适用的两种方法_javascript技巧

WBOY
WBOYOriginal
2016-05-16 17:27:341355browse
方法一:用CSS截断字符串:IE,FireFox,Opera ,Safari都兼容
复制代码 代码如下:

.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*/
}
任意长度文本

方法二:用js截取
复制代码 代码如下:



JQUERY 文本截取方法











我是代码:$.fn.substr = function(l,c){ $(this).each(function(i,item) 以下两种方式都可以解决textarea行高自动适应类容的高度 以下两种方式都可以解决textarea行


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn