<div class="content">
<span>测试文本内容:
脚本学堂_www.jb200.com,专业的网站建设、网站编程、系统管理类技术站点,欢迎大家的访问。</span>
<span>More↓</span>
</div>
<script type="text/
javascript">
/**
*
jquery 显示或隐藏文本
* www.jb200.com
* Edit: 2013/5/8 星期三
*/
$(function(){
$(".content").each(function(){
var $targetEle = $(this).find("span").first();
var $btnCtrl = $(this).find("span").last();
var strAll = $targetEle.text();
if (strAll.length >30)
{
var sonStr = strAll.substr(0,30);
$targetEle.text(sonStr)
$btnCtrl.click(function(){
if ($btnCtrl.text().substr(0,5)=="More↓")
{
$targetEle.text(strAll);
$btnCtrl.text("More↑");
}
else{
$targetEle.text(sonStr)
$btnCtrl.text("More↓");
}
});
}
else{$btnCtrl.text("")}
});
});
</script>