<div>This is my content containing some general large text to display ...
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum</div>
如何在点击 (...) 时实现阅读更多扩展内容的功能 没有任何其他嵌套的 Div 或
标签“只是一个 Div”
提前致谢
最佳答案
做类似的事情:
HTML
<div class="truncate">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>
CSS
.truncate {
width: 250px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
JavaScript
$(".truncate").click(function() {
$(this).removeClass("truncate");
});
关于javascript - 如何仅使用单个 div 实现阅读更多功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28294404/