Created
June 19, 2013 15:07
-
-
Save ituki/5815047 to your computer and use it in GitHub Desktop.
jQueryで表示文字数制限+α ref: http://qiita.com/ituki_b/items/2c1632b6d73a14d22061
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul> | |
<li class="textOverFlow02">開いて閉じる。あいうえおかきくけこさしすせそ</li> | |
<li class="textOverFlow02">開いて閉じる。あいうえおかきくけこさしすせそ</li> | |
<li class="textOverFlow02">開いて閉じる。あいうえおかきくけこさしすせそ</li> | |
<li class="textOverFlow02">開いて閉じる。あいうえおかきくけこさしすせそ</li> | |
<li class="textOverFlow02">開いて閉じる。あいうえおかきくけこさしすせそ</li> | |
<li class="textOverFlow02">開いて閉じる。あいうえおかきくけこさしすせそ</li> | |
<li class="textOverFlow02">開いて閉じる。あいうえおかきくけこさしすせそ</li> | |
<li class="textOverFlow02">開いて閉じる。あいうえおかきくけこさしすせそ</li> | |
<li class="textOverFlow02">開いて閉じる。あいうえおかきくけこさしすせそ</li> | |
<li class="textOverFlow02">開いて閉じる。あいうえおかきくけこさしすせそ</li> | |
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.moreLead { | |
color: blue; | |
cursor: pointer; | |
} | |
.textOverFlow02 .moreTxt { | |
display: none; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function(){ | |
function textOverFlow02(){ //表示文字数制限+α | |
var count = 10, | |
target = $('.textOverFlow02'); | |
$('.textOverFlow02').each(function(){ | |
$(this).html($(this).text().replace($(this).text().slice(count),'<span class="moreTxt">'+$(this).text().slice(count)+'</span><span>…</span><span class="moreLead">[全文表示]</span>')); | |
$('.moreLead',this).toggle(function(){ | |
$(this).text('[閉じる]').parent().children('.moreTxt').show().next().hide(); | |
},function(){ | |
$(this).text('[全文表示]').parent().children('.moreTxt').hide().next().show(); | |
}); | |
}); | |
} | |
textOverFlow02(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment