文字超长 显示省略号 展开 收起

留言总数 26 条 · 顶层留言 16 条 · 第 2 / 2 页 · 每页 15 条

返回插件详情
Wiki
.drug-text {
    white-space: nowrap;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis
}
<div>
    <p class="drug-text" value="true">texttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttext</p>
    <p class="drug-toggle">展开</p>
</div>
<script language="javascript">
    $(".drug-toggle").click(function () {
        var sign = $(this).val();
        sign = !sign;
        $(this).val(sign);
        if (sign) {
            $(this).prev().css("white-space", "inherit");
            $(this).html("收起");
        } else {
            $(this).prev().css("white-space", "nowrap");
            $(this).html("展开");
        }
    });
</script>
云淡风轻

表示没成功啊!