jQuery Expander Plugin:
HTML:
<div class="expandable">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor.
</p>
<p>Reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui
officia deserunt mollit anim id est laborum.
</p>
</div>
Javascript:
<script src="jquery.js" type="text/javascript"></script>
<script src="jquery.expander.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
// simple example, using all default options
$('div.expandable p').expander();
// *** OR ***
// override some default options
$('div.expandable p').expander({
slicePoint: 80, // default is 100
expandText: '[...]', // default is 'read more...'
collapseTimer: 5000, // re-collapses after 5 seconds; default is 0, so no re-collapsing
userCollapseText: '[^]' // default is '[collapse expanded text]'
});
});
</script>
Nguồn:
http://plugins.learningjquery.com/expander/index.html
Xem bản demo ở đây:
http://plugins.learningjquery.com/expander/demo/index.html
Chúc may mắn hỏi tôi nếu bạn cần làm rõ!
@Trufa - +1 Cảm ơn. – vikmalhotra
Không sao cả! nếu bạn cần bất kỳ sự trợ giúp nào thực hiện thì hãy hỏi! – Trufa
@Trufa - Có một câu hỏi về điều này. Tôi đang hiển thị chuỗi văn bản có thể mở rộng của mình trong danh sách. Vì vậy, có nhiều hàng văn bản có thể mở rộng. Nếu tôi gắn phương thức 'expander()' vào tất cả các hàng đó, điều này sẽ mở rộng tất cả các chuỗi khi nhấp vào 'expandText'? – vikmalhotra