您的位置:首页 > Web前端 > JQuery

jQuery使用插件dotdotdot.js实现段落溢出显示省略号

2017-07-14 10:27 661 查看
博客开发过程中遇到需要把多行文字溢出显示省略号,试过很多方法,感觉最好用的就是dotdotdot插件,下面介绍给大家使用。1.先上图给大家看看效果2.使用方法    引入插件
    
<
script
 
src
=
"jquery.dotdotdot.js"
 
type
=
"text/javascript"
></
script
>
   插件官网下载地址:http://dotdotdot.frebsite.nlCSS实例方法jquery.dotdotdot添加元素:
添加jquery.dotdotdot与窗口大小改变时更新单元:
添加jquery.dotdotdot与预定义的元素高度:
JavaScript方法创建一个DOM元素,把一些文本和其它的HTML标记在这个“wrapper”。html
js
3.配置选项dotdotdot插件使用可以在配置对象中传递的几个选项。所有选项(显示默认值):$(document).ready(function(){$("#wrapper").dotdotdot({/* The text to add as ellipsis. */ellipsis :'... ', /* How to cut off the text/html: 'word'/'letter'/'children' */wrap :'word', /* Wrap-option fallback to 'letter' for long words */fallbackToLetter:true, /* jQuery-selector for the element to keep and put after the ellipsis. */after :null, /* Whether to update the ellipsis: true/'window' */watch :false,/* Optionally set a max-height, can be a number or function.If null, the height will be measured. */height :null, /* Deviation for the height-option. */tolerance :0, /* Callback function that is fired after the ellipsis is added,receives two parameters: isTruncated(boolean), orgContent(string). */callback :function( isTruncated,orgContent ){}, lastCharacter :{ /* Remove these characters from the end of the truncated text. */remove :[' ',',',';','.','!','?'], /* Don't add an ellipsis if this array containsthe last character of the truncated text. */noEllipsis :[]}});});文章来源:http://www.tutiaoba.com/4.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  dotdotdot jquery 插件