日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

html5jqueryl轮播图,基于JQuery的实现图片轮播效果(焦点图)

發(fā)布時間:2025/3/15 编程问答 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 html5jqueryl轮播图,基于JQuery的实现图片轮播效果(焦点图) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

完整的演示代碼:

JQuery實現(xiàn)圖片輪播效果

#banner {position:relative; width:478px; height:286px; border:1px solid #666; overflow:hidden; font-size:16px}

#banner_list img {border:0px;}

#banner_bg {position:absolute; bottom:0;background-color:#000;height:30px;filter: Alpha(Opacity=30);opacity:0.3;z-index:1000;cursor:pointer; width:478px; }

#banner_info{position:absolute; bottom:4px; left:5px;height:22px;color:#fff;z-index:1001;cursor:pointer}

#banner_text {position:absolute;width:120px;z-index:1002; right:3px; bottom:3px;}

#banner ul {position:absolute;list-style-type:none;filter: Alpha(Opacity=80);opacity:0.8; z-index:1002;

margin:0; padding:0; bottom:3px; right:5px; height:20px}

#banner ul li { padding:0 8px; line-height:18px;float:left;display:block;color:#FFF;border:#e5eaff 1px solid;background-color:#6f4f67;cursor:pointer; margin:0; font-size:16px;}

#banner_list a{position:absolute;}

-->

【實例演示】

  • 1
  • 2
  • 3
  • 4

[Ctrl+A 全選 注:如需引入外部Js需刷新才能執(zhí)行]

【原理簡述】

這里大概說一下整個流程:

1,將除了第一張以外的圖片全部隱藏,

2,獲取第一張圖片的alt信息顯示在信息欄,并添加點擊事件

3,為4個按鈕添加點擊偵聽,點擊相應(yīng)的按鈕,用fadeOut,fadeIn方法顯示圖片

4,設(shè)置setInterval,定時執(zhí)行切換函數(shù)

【代碼說明】

filter(":visible") :獲取所有可見的元素

unbind():從匹配的元素中刪除綁定的事件

siblings:取得一個包含匹配的元素集合中每一個元素的所有唯一同輩元素的元素集合

例:找到每個div的所有同輩元素中帶有類名為selected的元素。

代碼如下:

Hello

Hello Again

And Again

執(zhí)行 $("div").siblings(),結(jié)果

代碼如下:

[

Hello

,

And Again

]

【程序源碼】

HTML部分:

代碼如下:

  • 1
  • 2
  • 3
  • 4

CSS部分:

代碼如下:

#banner {position:relative; width:478px; height:286px; border:1px solid #666; overflow:hidden;}

#banner_list img {border:0px;}

#banner_bg {position:absolute; bottom:0;background-color:#000;height:30px;filter: Alpha(Opacity=30);opacity:0.3;z-index:1000;cursor:pointer; width:478px; }

#banner_info{position:absolute; bottom:0; left:5px;height:22px;color:#fff;z-index:1001;cursor:pointer}

#banner_text {position:absolute;width:120px;z-index:1002; right:3px; bottom:3px;}

#banner ul {position:absolute;list-style-type:none;filter: Alpha(Opacity=80);opacity:0.8; border:1px solid #fff;z-index:1002;

margin:0; padding:0; bottom:3px; right:5px;}

#banner ul li { padding:0px 8px;float:left;display:block;color:#FFF;border:#e5eaff 1px solid;background-color:#6f4f67;cursor:pointer}

#banner_list a{position:absolute;}

JS部分:

代碼如下:

var t = n = 0, count;

$(document).ready(function(){

count=$("#banner_list a").length;

$("#banner_list a:not(:first-child)").hide();

$("#banner_info").html($("#banner_list a:first-child").find("img").attr('alt'));

$("#banner_info").click(function(){window.open($("#banner_list a:first-child").attr('href'), "_blank")});

$("#banner li").click(function() {

var i = $(this).text() - 1;//獲取Li元素內(nèi)的值,即1,2,3,4

n = i;

if (i >= count) return;

$("#banner_info").html($("#banner_list a").eq(i).find("img").attr('alt'));

$("#banner_info").unbind().click(function(){window.open($("#banner_list a").eq(i).attr('href'), "_blank")})

$("#banner_list a").filter(":visible").fadeOut(500).parent().children().eq(i).fadeIn(1000);

$(this).css({"background":"#be2424",'color':'#000'}).siblings().css({"background":"#6f4f67",'color':'#fff'});

});

t = setInterval("showAuto()", 4000);

$("#banner").hover(function(){clearInterval(t)}, function(){t = setInterval("showAuto()", 4000);});

})

function showAuto()

{

n = n >=(count - 1) ? 0 : ++n;

$("#banner li").eq(n).trigger('click');

}

總結(jié)

以上是生活随笔為你收集整理的html5jqueryl轮播图,基于JQuery的实现图片轮播效果(焦点图)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。