多行文本溢出显示省略号(…)全攻略

本文介绍了两款JS库——Clamp.js和jQuery.dotdotdot,详细介绍了它们的功能、使用方法及特点。Clamp.js是一款用于多行文本内容的高级跨浏览器省略工具,而jQuery.dotdotdot则是一个jQuery插件,专门用于实现复杂且跨浏览器的文本省略效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

原文:http://www.css88.com/archives/5206

这里介绍一下2个js库 Clamp.js和jQuery.dotdotdot,它们非常不错哦。

Clamp.js地址:https://github.com/josephschmitt/Clamp.js  2.475 kb(压缩库)

jQuery.dotdotdot地址:https://github.com/BeSite/jQuery.dotdotdot  6.15kb(压缩库)

A jQuery plugin for advanced cross-browser ellipsis on multiple line content.
Demo's and documentation: http://dotdotdot.frebsite.nl

How to use the plugin

Include all nessesary .js-files inside the head-tag of the page.

<head>
    <script src="jquery.js" type="text/javascript"></script>
    <script src="jquery.dotdotdot.js" type="text/javascript"></script>
</head>

Create a DOM element and put some text and other HTML markup in this "wrapper".

<div id="wrapper">
    <p>Lorem Ipsum is simply dummy text.</p>
</div>

Fire the plugin onDocumentReady using the wrapper-selector.

$(document).ready(function() {
    $("#wrapper").dotdotdot({
        // configuration goes here
    });
});


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值