欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

JQERY limittext 插件0.2版(長內(nèi)容限制顯示)

 更新時(shí)間:2010年08月27日 20:10:17   作者:  
JQERY limittext 插件為長內(nèi)容增加一個(gè)顯示更多的功能
增加一個(gè)顯示更多的功能 附上代碼:使用實(shí)例在附件
復(fù)制代碼 代碼如下:

/**
* demo:
* 1.$("#limittext").limittext();
* 2.$("#limittext").limittext({"limit":1});
* 3.$("#limittext").limittext({"limit":1,"fill":"......","morefn":{"status":true}});
* 4.$("#limittext").limittext({"limit":1,"fill":"......","morefn":{"status":true,"moretext":"更多","lesstext":"隱藏部分","fullfn":function(){alert("more")},"lessfn":function(){alert("less")}}})
* 5.$("#limittext").limittext({"limit":1,"fill":"......","morefn":{"status":true}}).limit("all");
* @param {Object} opt
* {
* limit:30,//顯示文字個(gè)數(shù)
* fill:'...'//隱藏時(shí)候填充的文字
* morefn:{
* status:false,//是否啟用更多
* moretext: "(more)",//隱藏部分文字時(shí)候顯示的文字
* lesstext:"(less)",//全部文字時(shí)候顯示的文字
* cssclass:"limittextclass",//啟用更多的A標(biāo)簽的CSS類名
* lessfn:function(){},//當(dāng)文字為更少顯示時(shí)候回調(diào)函數(shù)
* fullfn:function(){}//當(dāng)文字為更多時(shí)候回調(diào)函數(shù)
* }
* @author Lonely
* @link http://www.liushan.net
* @version 0.2
*/
jQuery.fn.extend({
limittext:function(opt){
opt=$.extend({
"limit":30,
"fill":"..."
},opt);
opt.morefn=$.extend({
"status": false,
"moretext": "(more)",
"lesstext":"(less)",
"cssclass": "limittextclass",
"lessfn": function(){
},
"fullfn": function(){
}
},opt.morefn);
var othis=this;
var $this=$(othis);
var body=$this.data('body');
if(body==null){
body=$this.html();
$this.data('body',body);
}
var getbuttom=function(showtext){
return "<a href='javascript:;' class='"
+opt.morefn.cssclass+"'>"
+showtext
+"<a>";
}
this.limit=function(limit){
if(body.length<=limit||limit=='all'){
var showbody=body+(opt.morefn.status?getbuttom(opt.morefn.lesstext):"");
}else{
if(!opt.morefn.status){
var showbody=body.substring(0,limit)
+opt.fill;
}else{
var showbody=body.substring(0,limit)
+opt.fill
+getbuttom(opt.morefn.moretext);
}
}
$this.html(showbody);
}
this.limit(opt.limit);
$("."+opt.morefn.cssclass).live("click",function(){
if($(this).html()==opt.morefn.moretext){
showbody=body
+getbuttom(opt.morefn.lesstext);
$this.html(showbody);
opt.morefn.fullfn();
}else{
othis.limit(opt.limit);
opt.morefn.lessfn();
}
});
return this;
}
});

打包下載地址 http://www.dbjr.com.cn/jiaoben/29345.html

相關(guān)文章

最新評(píng)論