我有超过500个字符的段落.我想只获得最初的100个字符并隐藏其余部分.另外我想在100个字符旁边插入"更多"链接.点击更多链接整个段落应显示并编辑文本"更多"到"更少",点击"更少"它应切换行为.段落是动态生成的,我无法使用.wrap()包装它的内容.这是我拥有的和我想要的例子.
这就是我所拥有的:
<p>It is a long established fact that a reader will be distracted by the readable
content of a page when looking at its layout. The point of using Lorem Ipsum is that
it has a more-or-less normal distribution of letters, as opposed to using 'Content
content here', making it look like readable English. Many desktop publishing packages
and web page editors now use Lorem Ipsum as their default model text.</p>
Run Code Online (Sandbox Code Playgroud)
这是DOM加载时我想要的
<p>It is a long established fact that …Run Code Online (Sandbox Code Playgroud)