下面是我的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>
答案 0 :(得分:6)
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 */}