相关疑难解决方法(0)

jQuery文本截断(阅读更多样式)

我的问题非常类似于" 修剪文字到340个字符 ",但在jQuery中.这听起来很直接,但当我四处搜索时,我找不到任何参考资料.

好吧,我有一个div $('#content')我想将文本修剪为'x'字符数量让我们说'600' 但是我不希望它打破它自己的单词!喜欢不' 问题...... '但' 问题...... '.

其他文本会发生什么?好吧,我隐藏了它,并会根据要求显示它!但是等一下,它应该首先删除' ... '并在它隐藏之后显示文本.

以下是$('#content')的示例结构:

<div id="content">
    <p>Once upon a midnight dreary, while I pondered weak and weary,Over many a quaint and curious volume of forgotten lore.</p>
    <p>Writing example text is very boring.</p>
    <p>Specially when you are dumb enough not to copy and paste. Oh!</p>
    <p>Once it sheltered the rogues and rapscallions of the British Empire; now Kangaroo Island is ready and waiting for some derring-do …
Run Code Online (Sandbox Code Playgroud)

jquery text trim

23
推荐指数
3
解决办法
4万
查看次数

jQuery中的字限制器(在XX字符后切断最近的空格并添加......'阅读更多')

可能重复:
如何在jQuery中截断字符串?

我正在使用jQuery从Facebook提取订阅源,并希望限制每个消息字符串中显示的字/字符数.

即如果字符串包含超过100个字符,它应该停在最近的空格并放入"...阅读更多"

我怎么能这样做呢?

javascript jquery

1
推荐指数
1
解决办法
3040
查看次数

标签 统计

jquery ×2

javascript ×1

text ×1

trim ×1