相关疑难解决方法(0)

截断段前100个字符并隐藏段落的其余内容以显示/隐藏更多/更少链接的休息符号

我有超过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)

javascript xhtml jquery

17
推荐指数
1
解决办法
3万
查看次数

标签 统计

javascript ×1

jquery ×1

xhtml ×1