当前位置: 首页 > 图文教程 > 网络编程 > Javascript > jQuery 插件 将this下的div轮番显示

Javascript
form中限制文本字节数js代码
use jscript with List Proxy Server Information
use jscript List Installed Software
List Installed Software Features
List Information About the Binary Files Used by an Application
List the Codec Files on a Computer
List the UTC Time on a Computer
List Installed Hot Fixes
excel操作之Add Data to a Spreadsheet Cell
Add Formatted Data to a Spreadsheet
Apply an AutoFormat to an Excel Spreadsheet
JavaScript语法着色引擎(demo及打包文件下载)
类之Prototype.js学习
一款JavaScript压缩工具:X2JSCompactor
iis6+javascript Add an Extension File
jscript之Open an Excel Spreadsheet
jscript之Read an Excel Spreadsheet
jscript之List Excel Color Values
去除图像或链接黑眼圈的两种方法总结
Add a Formatted Table to a Word Document

Javascript 中的 jQuery 插件 将this下的div轮番显示


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-12   浏览: 440 ::
收藏到网摘: n/a

将this下的div轮番显示 dname指定需要执行此动作的元素,如果没有指定dname,将默认全部子元素

复制代码 代码如下:

/*
将this下的div轮番显示
dname指定需要执行此动作的元素,如果没有指定dname,将默认全部子元素;
tname指定与dname对应的激活元素;
speed显示切换速度;
effe显示的效果;
*/
(function(){
.fn.w_picSwap=function(dname,tname,speed,effe){
speed=speed || 2000;
dname=dname || "";
tname=tname || "";
effe=effe || 1;
return this.each(function(){
var myTime;
var obj=(this);
var objs=(this).find(dname);
var objnl=(this).find(tname).not(dname);
var len2=objnl.length;
var len=objs.length;
if(len<2){ return;}
var si=0;
var old=0;
objs.not(':first').css('opacity',0);
function showImg(){
old=si;si=(si==(len-1))?0:si+1;
effect(objs.eq(old),objs.eq(si));
if(len2){
objnl.eq(old).removeClass("on");
objnl.eq(si).addClass("on");
}
};
function effect(o,n){
switch(effe){
case 1:
o.stop().animate({opacity:0});
n.stop().animate({opacity:1});
break;
case 2:
var toff=o.position();
n.stop().css("top",toff.top+o.outerHeight()).animate({top:toff.top,opacity:1},200);
o.stop().animate({top:toff.top-o.outerHeight(),opacity:0});
break;
}
}
function begin(){
myTime = setInterval(showImg,speed);
};
objnl.mouseover(function(){
si=objnl.index(this);
showImg();
});
//滑入 停止动画,滑出开始动画.
obj.hover(function(){
if(myTime){clearInterval(myTime);}
},function(){
begin();
});
begin();
});
};
})(jQuery);