jquery picswitch图片焦点图展示效果 - Web前端
作者:98wpeu发布时间:2026-06-20分类:网页前端技术浏览:3
导读:效果如下:这个插件的要点之处就在JQuery-1.4.2.JS的发布添加的新函数data的应用,所以jQuery库一定要是1.4.2的版本另一方面就是CSS的编写,SetInte...
效果如下:
这个插件的要点之处就在JQuery-1.4.2.JS的发布添加的新函数data的应用,所以jQuery库一定要是1.4.2的版本
另一方面就是CSS的编写,SetInterval和setTimeout的用法,前者是每隔多长时间执行一次,后者是多长时间执行一次;
关于settimeout的用法 有二种形式 1 settimeout(code,interval) 中的code是字符串
2 setTimeout(func,interval,args) 中的func是函数
实现代码
jquery slidepictrue *{ margin:0px; padding:0px; list-style:none; } body{ font-size:12px; color:white} #imageShow { position:relative;z-index:3;overflow:hidden;width:586px;height:150px } #imageShow #imageswitch { position:absolute;right:0px;bottom:0px;padding-left:50px;z-index:4; background-color:#C08A93;filter:Alpha(opacity=70); opacity:0.7;} #imageShow #imageSwitch li{ float:left;border-left:1px solid white;height:14px;width:30px; text-align:center;line-height:14px;} $(function(){ $imageShow=$("#imageShow"); $images=$("#imageSrc li",$imageShow); $imageSwitches=$("#imageSwitch li",$imageShow); //判断图片的张数,如果有图片 if($images.size()>0){ init(); //利用setInterval设置延迟时间,一直执行每隔1秒执行autoSwitch函数, var timer=setInterval(autoSwitch,1000); //遍历函数 $imageSwitches.each(function(index,item){ $(item).click(function(){ clearInterval(timer); // setTimeout有二种形式,第一种 setTimeout(code,interval),code是字符串,第二种 // setTimeout(func,interval,args),func是函数表达式,而不是语句 setTimeout(function(){timer=setInterval(autoSwitch,1000)},1000); $imageSwitches.css('background-color','').eq(index).css('background-color','#FF3366'); //现在用到了data函数,用于图片和下表对照 if(index!=$imageShow.data('show')){ $imageShow.data('show',index); $images.hide().eq(index).fadeIn('slow'); } }) }) } //自动显示的函数 function autoSwitch(){ $nowIndex=$imageShow.data('show')+1; if($images.size()>$nowIndex){ $imageSwitches.css('background-color','').eq($nowIndex).css('background-color','#FF3366'); $imageShow.data('show',$nowIndex); $images.hide().eq($nowIndex).fadeIn('slow'); }else{ init(); } } //初始化到第一张图片开始 function init(){ $imageShow.data('show',0); $images.hide().eq(0).fadeIn('slow'); $imageSwitches.css('background-color','').eq(0).css('background-color','#FF3366'); } });
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]

这个插件的要点之处就在JQuery-1.4.2.JS的发布添加的新函数data的应用,所以jQuery库一定要是1.4.2的版本
另一方面就是CSS的编写,SetInterval和setTimeout的用法,前者是每隔多长时间执行一次,后者是多长时间执行一次;
关于settimeout的用法 有二种形式 1 settimeout(code,interval) 中的code是字符串
2 setTimeout(func,interval,args) 中的func是函数
实现代码
jquery slidepictrue *{ margin:0px; padding:0px; list-style:none; } body{ font-size:12px; color:white} #imageShow { position:relative;z-index:3;overflow:hidden;width:586px;height:150px } #imageShow #imageswitch { position:absolute;right:0px;bottom:0px;padding-left:50px;z-index:4; background-color:#C08A93;filter:Alpha(opacity=70); opacity:0.7;} #imageShow #imageSwitch li{ float:left;border-left:1px solid white;height:14px;width:30px; text-align:center;line-height:14px;} $(function(){ $imageShow=$("#imageShow"); $images=$("#imageSrc li",$imageShow); $imageSwitches=$("#imageSwitch li",$imageShow); //判断图片的张数,如果有图片 if($images.size()>0){ init(); //利用setInterval设置延迟时间,一直执行每隔1秒执行autoSwitch函数, var timer=setInterval(autoSwitch,1000); //遍历函数 $imageSwitches.each(function(index,item){ $(item).click(function(){ clearInterval(timer); // setTimeout有二种形式,第一种 setTimeout(code,interval),code是字符串,第二种 // setTimeout(func,interval,args),func是函数表达式,而不是语句 setTimeout(function(){timer=setInterval(autoSwitch,1000)},1000); $imageSwitches.css('background-color','').eq(index).css('background-color','#FF3366'); //现在用到了data函数,用于图片和下表对照 if(index!=$imageShow.data('show')){ $imageShow.data('show',index); $images.hide().eq(index).fadeIn('slow'); } }) }) } //自动显示的函数 function autoSwitch(){ $nowIndex=$imageShow.data('show')+1; if($images.size()>$nowIndex){ $imageSwitches.css('background-color','').eq($nowIndex).css('background-color','#FF3366'); $imageShow.data('show',$nowIndex); $images.hide().eq($nowIndex).fadeIn('slow'); }else{ init(); } } //初始化到第一张图片开始 function init(){ $imageShow.data('show',0); $images.hide().eq(0).fadeIn('slow'); $imageSwitches.css('background-color','').eq(0).css('background-color','#FF3366'); } });
- 1
- 2
- 3
- 4
- 5
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
相关推荐
- JQuery UI DatePicker中z-index默认为1的解决办法 - Web前端
- Jquery跨域获得Json时invalid label错误的解决办法 - Web前端
- jQuery 表单验证扩展(三) - Web前端
- 使用jquery与图片美化checkbox和radio控件的代码(打包下载) - Web前端
- jQuery实现form表单reset按钮重置清空表单功能 - Web前端
- 13个绚丽的Jquery 界面设计网站推荐 - Web前端
- 通过jQuery打造支持汉字,拼音,英文快速定位查询的超级select插件 - Web前端
- jquery picswitch图片焦点图展示效果 - Web前端
- jquery 实现表单验证功能代码(简洁) - Web前端
- jQuery入门第一课 jQuery选择符 - Web前端
- 网页前端技术排行
-
- 1【第六章】Foundation之按钮和下拉功能 - Web前端
- 2jQuery编写widget的一些技巧分享 - Web前端
- 3在Mac/PC上远程调试iPhone/iPad上的网页 - Web前端
- 4基于jquery的滚动条滚动固定div(附演示下载) - Web前端
- 5分析Iconfont-阿里巴巴矢量常用图标库 - Web前端
- 6jQuery实例教程:制作网页中可折叠的面板 - Web前端
- 7分享精心挑选的12款优秀jQuery Ajax分页插件和教程 - Web前端
- 8[Web前端]用javascript实现默认图片替代未显示的图片 - Web前端
- 9JS网页制作实例:标签云 - Web前端
- 最近发表
-
- WordPress随机显示特色图片插件:Random Post Thumbnails
- KeePass实现Chrome浏览器自动填充密码方法一
- LNMP一键包nginx 301强制跳转到https教程
- KeePass实现Chrome浏览器自动填充密码方法二
- #建站# 免费的VPS管理软件Xshell8/Xftp8中文版下载
- 使用Xshell 8连接VPS教程_电脑登录vps的方法
- WordPress评论界面添加烟花????效果
- 不同浏览器书签同步方案:坚果云+Floccus_详细使用教程
- iOS端KeePassXC客户端APP:Strongbox Password Safe
- 给WordPress评论中的Gravatar头像图片添加ALT属性







