요소 내에서 텍스트를 자동으로 단축하고 "More"링크를 추가하는 간단한 jQuery 플러그인.
튜토리얼 읽기 : jQuery shorten.
'요소'내에서 텍스트를 단축하고 'More'링크를 추가합니다.
$(element).shorten();
요소의 내용을 단축하면서 텍스트 '더 읽기'로 링크를 추가하십시오.
$(element).shorten({
moreText: 'read more'
});
링크 텍스트를 '더 읽기'로 변경하고 '기본값을 우선적 인 기본 값'더 읽기 '및'Less '로 변경하십시오.
$(element).shorten({
moreText: 'read more',
lessText: 'read less'
});
기본 표시 100 문자를 재정의하고 50 자 이상의 텍스트를 숨 깁니다.
$(element).shorten({
showChars: 50,
});
다음 JS 변수를 변경하여 동작을 변경할 수 있습니다.
재산 | 설명 |
---|---|
showChars | 사용자에게 보여줄 총 문자. 콘텐츠가 Showchar보다 더 많으면 두 개의 반쪽으로 나누고 첫 번째는 사용자에게 표시됩니다. |
ellipsesText | "More"링크 앞에 표시된 텍스트. 기본값은“…”입니다. |
moreText | 더 많은 링크에 표시된 텍스트. 기본값은 "More"입니다. ">>"또는 "더 읽기"로 변경할 수 있습니다. |
lessText | 적은 링크에 표시된 텍스트. 기본값은 "적은"것입니다. "<<"또는 "덜 읽기"로 변경할 수 있습니다. |
onMore | "more"를 클릭 할 때 트리거하는 콜백 함수 |
onLess | "Less"를 클릭 할 때 트리거하는 콜백 함수 |
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.