gpt4 book ai didi

javascript - 如何使用 CSS3 设置 "Read More"的样式

转载 作者:行者123 更新时间:2023-11-28 15:50:21 26 4
gpt4 key购买 nike

下面是我的 JQuery 函数。我想将 CSS 样式应用于“Read More”和“Read Less”文本,它们是函数的一部分。我们如何做到这一点?

$(document).ready(function() { 
$('.YourName').jTruncate({
length: 25,
minTrail: 0,
moreText: "Read More",
lessText: "Read Less",
ellipsisText: "...",
});
});
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> 
<script type="text/javascript" src="http://tester3.yolasite.com/resources/javascript/jtruncate.js"></script>

<p class="YourName">Hello, Text will truncate after 25 characters and a "Read More" link will be appended to it. Here is some more text. Here is some more text. Here is some more text. Here is some more text. Here is some more text. Here is some more more text. Here is some more text. Here is some more text. This is the end.</p>

最佳答案

moreText: "<span class='moreText'>Read More</span>", // The text to use for the "more" link. 
lessText: "<span calss='readLess'>Read Less</span>", // The text to use for the "less" link.

然后像往常一样在你的 css 中设置它们的样式......

.moreText{/* styles here */}
.readLess{/* styles here */}

关于javascript - 如何使用 CSS3 设置 "Read More"的样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40468672/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com