jQuery 插件“readmore”,修剪文本而不剪词
我正在使用 http://rockycode.com/blog/jquery-plugin-readmore/ 用于修剪长文本并添加“查看更多”链接以显示所有文本。
我很想避免说废话,我该怎么做呢?
如果限制为 35,则不要剪切 w...
但
如果限制为 35,则不要剪切单词...(在本例中,将其修剪为 38,然后显示第 39 条中的隐藏文本结束。
I'm using http://rockycode.com/blog/jquery-plugin-readmore/ for trim long text and add a "See more" link to reveal all the text.
I would love to avoid cutting words, how could I do that?
If the limit is 35, don't cut the w...
but
If the limit is 35, don't cut the word... (and in this case, trim it at 38 and then show the hidden text from 39th chtill the end.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我只是在收集有关此主题的信息,在您的帮助和其他相关帖子的帮助下,我写了以下内容:
http:// /jsfiddle.net/KHd6J/526/
I was just gathering information about this subject, with your help and the help from other related posts I wrote this:
http://jsfiddle.net/KHd6J/526/
这样做,而不是这样做:
您可以
我们正在做的是转到索引 35 之前的最新可能空间。
当然35可以是可变的。您也可以将其放入函数中以重用它。
希望这有帮助
Instead of doing this:
You could do this
What we're doing is to go to the latest space posible before index 35.
Of course 35 can be variable. Also you could put it into a function to reuse it.
Hope this helps
您可以按如下方式更改该插件中的
abridge
函数:...它会按照您的意愿运行。您可能想要添加一个选项来关闭和打开此功能,但我会将其留给您。
查看工作示例→
You can change the
abridge
function within that plugin as follows:...and it will behave as you desire. You might want to add an option to turn this feature off and on, but I'll leave that up to you.
See working example →