Plugin jQuery sederhana yang secara otomatis memperpendek teks dalam suatu elemen dan menambahkan tautan "lebih banyak".
Baca Tutorial: JQuery Shorten.
Mempersingkat teks di dalam 'elemen' dan tambahkan tautan 'lebih'.
$(element).shorten();
Tambahkan tautan dengan teks 'Baca lebih lanjut' sambil memperpendek konten elemen.
$(element).shorten({
moreText: 'read more'
});
Ubah teks tautan menjadi 'baca lebih lanjut' dan 'baca lebih sedikit' menimpa nilai default 'lebih' dan 'kurang'.
$(element).shorten({
moreText: 'read more',
lessText: 'read less'
});
Override Default Display 100 Karakter dan Sembunyikan teks di atas 50 karakter.
$(element).shorten({
showChars: 50,
});
Anda dapat mengubah perilaku dengan mengubah variabel JS berikut.
Milik | Keterangan |
---|---|
showChars | Total karakter untuk ditampilkan kepada pengguna. Jika konten lebih dari ShowChar, itu akan dibagi menjadi dua bagian dan yang pertama akan ditunjukkan kepada pengguna. |
ellipsesText | Teks yang ditampilkan sebelum tautan "lebih". Default adalah "..." |
moreText | Teks yang ditampilkan di lebih banyak tautan. Default adalah "lebih". Anda dapat mengubah ke ">>" atau "baca lebih lanjut" |
lessText | Teks yang ditampilkan di Less Link. Default adalah "lebih sedikit". Anda dapat mengubah menjadi "<<" atau "Baca lebih sedikit" |
onMore | Fungsi panggilan balik untuk memicu saat "lebih" diklik |
onLess | Fungsi panggilan balik untuk memicu saat "kurang" diklik |
Copyright 2013 Viral Patel and other contributors
http://viralpatel.net
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.