W Wiki 2015-12-22 15:12 .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> 云 云淡风轻 2015-12-22 15:12 表示没成功啊!
.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>