JS实现的简单的图片轮换
2010-06-24 17:51
851 查看
-----------------------------此种做法是根据网上的做法改版--------------- -----------------------效果展示页:http://hangzhou.mainaer.com/shangchengqu/4.htm------------------- <div class ="decbL" > <style type ="text/css" > .imgsBox {overflow:hidden;width:330px;position:relative;height:200px;} .clickButton {background-color:#888888;position:absolute;bottom:0;right:0;} .clickButton a {background-color:#666;border-left:#ccc 1px solid;line-height:15px;height:15px;font-size:12px;float:left;padding:0 7px;text-decoration:none;color:#fff;} .clickButton a.active,.clickButton a:hover{background-color:#d34600;} </style > <div id ="imageSwithContainer" class ="imgsBox" > <div class ="imgs" ><a href =" # " ><img id ="pic" width ="330" height ="205" ></a ></div >
<div class ="clickButton" > <div id ="navBarClickBar4DHZ" ></div > </div > </div ><script language ="JavaScript" type ="text/javascript" > $("#imageSwithContainer").ready(function() { $.ajax( { url:"http://"+location.host+"/Ajax/getProductHotImages.ashx", type: "GET", data: { ProID: 4 }, dataType: "json", success: function(retData) { if (retData.result == 0){ $("#imageSwithContainer img[@id='pic']").attr("src","http://www.mainaer.com/uploadfiles/mainaer/nopic.gif"); return; } var arryImgs = []; for (var i = 0; i < retData.data.length; i++) { arryImgs.push(retData.data[i].ImageUrl); if (i == 0) { $("<a></a>").attr({ "href": "", "class": "active" }).html(i + 1).appendTo("#navBarClickBar4DHZ"); } else { $("<a></a>").attr({ "href": "", "class": "" }).html(i + 1).appendTo("#navBarClickBar4DHZ"); } } $(".clickButton a").attr("href", "javascript:void();"); var CNT = arryImgs.length+1; var times = 1; function changeImage() { if (times == CNT) { times = 1; } $(".clickButton a").removeClass("active"); $(".clickButton a:nth-child(" + times + ")").addClass("active"); $(".imgs img").attr("src", arryImgs[times - 1]); times++; } var interval = window.setInterval(function() { changeImage(); }, 1500); $(".clickButton a").each(function(index) { $(this).hover( function() { $(".clickButton a").removeClass("active"); $(this).addClass("active"); clearInterval(interval); $(".imgs img").attr("src", arryImgs[index]); times = index + 1; }, function() { interval = window.setInterval(function() { changeImage(); }, 1500); } ); }); } }); }); </script > </div >
相关文章推荐
- JS实现的简单的图片轮换
- JS实现简单的图片轮换效果
- html中利用js实现简单图片轮换效果
- JS实现的简单图片切换功能示例【测试可用】
- javascript+xml实现简单图片轮换(只支持IE)
- js实现简单的单击图片放大功能---仿新浪微博图片放大效果
- JS实现图片的不间断连续滚动的简单实例
- JS实现图片延迟加载并淡入淡出效果的简单方法
- 用js实现的一个Flash滚动轮换显示图片代码生成器
- 一个图片轮换显示的实现,使用DIV+JS,支持Firefox,IE,Safiri
- JS图片自动轮换效果实现
- jquery 实现简单的图片轮换
- javaBean+JSP+JS+XML实现从发布文章中自动提取图片在首页轮换效果
- 教你用js超简单实现页面自动控制图片的宽度和高度
- 原生 JS怎么 实现最简单的图片懒加载
- js---点击radio按钮实现图片轮换(two methds)
- 图片、切换-js实现图片轮换效果-by小雨
- JQ简单实现图片轮换
- 利用JS实现简单的瀑布流加载图片效果
- 利用js实现简单的图片切换(上下张切换)