企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
### html ``` ~~~ <div> <p class="context line5">{$v.content}</p> <a href="#" class="more">全文</a> </div> ~~~ ``` ### Jquery ``` ~~~ //判断是否需要 更多 来查看全部 function checkScroll(el) { if (el) { if (el.scrollHeight - el.clientHeight > parseFloat($(el).css('line-height')) / 2) { return true; } if (el.scrollWidth > el.offsetWidth) { return true; } } return false; } $('.comments .line5').each(function () { var $this = $(this); if (checkScroll(this)) { $($this).next('.more').css('display','block'); $('.more').click(function (e) { e.preventDefault(); $(this).hide(); $($this).css('display','block'); }); } }) ~~~ ```