隐藏部分文字html,css,javascript

问题描述:

如何隐藏 div span 中的部分文字?

How to hide part of the text inside div or span ?

我有160个字符的文字,但我只想显示前40个。

I have a text of 160 characters but I would like to display only first 40.

我必须在我的 div span 中有完整的文本,因为我在做javascript搜索。

I have to have the complete text inside my div, span as I do javascript searches.

您需要一些javascript来创建隐藏它们的最后120个字符的范围。有一个CSS属性visibility:hidden,可以应用于span。

You will need some javascript to create a span arround the last 120 characters that hides them. There is a CSS attribute "visibility:hidden" that can be applied to the span.

类似这样的结果应该是结果:

Something like that should be the result:

<div>first 40 chars <span style="visibility:hidden">last 120 chars</span></div>