Un complemento JQuery simple que acorta automáticamente el texto dentro de un elemento y agregue el enlace "más".
Leer Tutorial: JQuery Shorten.
Acorta el texto dentro de 'Elemento' y agregue un enlace 'más'.
$(element).shorten();
Agregue un enlace con el texto 'Leer más' mientras acorta el contenido del elemento.
$(element).shorten({
moreText: 'read more'
});
Cambie el texto del enlace a 'leer más' y 'leer menos' valor predeterminado anular 'más' y 'menos'.
$(element).shorten({
moreText: 'read more',
lessText: 'read less'
});
Anular la visualización predeterminada de 100 caracteres y ocultar texto por encima de 50 caracteres.
$(element).shorten({
showChars: 50,
});
Puede cambiar el comportamiento cambiando las siguientes variables JS.
Propiedad | Descripción |
---|---|
showChars | Total de caracteres para mostrar al usuario. Si el contenido es más que Showchar, se dividirá en dos mitades y primero se mostrará al usuario. |
ellipsesText | El texto se muestra antes del enlace "más". El valor predeterminado es "..." |
moreText | El texto que se muestra en más enlace. El valor predeterminado es "más". Puede cambiar a ">>" o "leer más" |
lessText | El texto que se muestra en menos enlace. El valor predeterminado es "menos". Puede cambiar a "<<" o "leer menos" |
onMore | La función de devolución de llamada se activará cuando se hace clic "Más" |
onLess | La función de devolución de llamada se activará cuando se hace clic "Menos" |
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.