小编Ste*_*imo的帖子

有没有办法通过jQuery获取CSS截断文本?

我试图从CSS截断元素中获取HTML并且似乎无法正确使用它.

例如:

<span id=mySpan style=white-space:nowrap;overflow:hidden;text-overflow:ellipsis;width:50px>This is the contents of the span tag.  It should truncate with an ellipsis if it is longer than 50px.</span>
Run Code Online (Sandbox Code Playgroud)

如果我使用标准的jQuery方式来获取HTML,我会得到全文,而不是截断的版本.我不确定它是否可能.

html = jQuery('#mySpan').html();
text = jQuery('#mySpan').text();
Run Code Online (Sandbox Code Playgroud)

两者都返回全文.我很难过.

html javascript css jquery

25
推荐指数
2
解决办法
2067
查看次数

标签 统计

css ×1

html ×1

javascript ×1

jquery ×1