- <html>
- <head>
- <title>图片切换,带标题文字</title>
- <script type="text/javascript" src1="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
- <style type="text/CSS">
- body,h1,h2,h3,h4,h5,h6,p,ul,li,dl,dt,dd{padding:0;margin:0;font-size:12px;font-family:Arial,Verdana, Helvetica, sans-serif;word-break:break-all;word-wrap:break-word;}
- li{list-style:none;}img{border:none;}em{font-style:normal;}
- a{color:#555;text-decoration:none;outline:none;blr:this.onFocus=this.blur();}
- a:hover{color:#000;text-decoration:underline;}
- .clear{height:0;overflow:hidden;clear:both;}
- .play{width:500px;height:230px;border:#ccc 1px solid; text-align:left; margin:30px;}
- .textbg{margin-top:200px;z-index:1;filter:alpha(opacity=40);opacity:0.4;width:500px;position:absolute;height:30px;background:#000;}
- .text{margin-top:200px;z-index:2;padding-left:10px;font-size:14px;font-weight:bold;width:340px;color:#fff;line-height:30px; overflow:hidden;position:absolute;cursor:pointer;}
- .num{margin:205px 5px 0 350px;z-index:3;width:145px; text-align:right;position:absolute;height:25px;}
- .num a{margin:0 2px;width:20px;height:20px;font-size:14px; font-weight:bold;line-height:20px;cursor:pointer;color:#000;padding:0 5px;background:#D7D6D7;text-align:center}
- .num a.on{background:#FFD116;color:#A8471C;}
- .num a.on2{background:#D7D6D7;color:#000;}
- .content img{width:500px;height:230px;}
- </style>
- </head>
- <body>
- <div class="play">
- <ul>
- <li class="textbg"></li>
- <li class="text"></li>
- <li class="num"><a>1</a><a>2</a><a>3</a><a>4</a><a>5</a><a>6</a></li>
- <li class="content">
- <a href="#" target="_blank"><img src1="http://ww1.sinaimg.cn/mw690/67b16bb3jw1e23pq33eapj.jpg" alt="澳大利亚:体验蓝山风光,感受澳洲风情" /></a>
- <a href="#" target="_blank"><img src1="http://tp4.sinaimg.cn/1739680691/180/22837370791/0" alt="九月抄底旅游,马上行动" /></a>
- <a href="#" target="_blank"><img src1="http://ww2.sinaimg.cn/large/67b16bb3jw1e2xogq44fhj.jpg" alt="港澳旅游:超值特价,奢华享受" /></a>
- <a href="#" target="_blank"><img src1="http://ww2.sinaimg.cn/large/67b16bb3jw1e2xogq44fhj.jpg" alt="炎炎夏日哪里去,途牛带你海滨游" /></a>
- <a href="#" target="_blank"><img src1="http://ww1.sinaimg.cn/mw690/67b16bb3jw1e2kpvdvvyfj.jpg" alt="定途牛旅游线路,优惠购买乐相册" /></a>
- <a href="#" target="_blank"><img src1="http://ww4.sinaimg.cn/mw690/67b16bb3jw1e1ue7bhcidj.jpg" alt="三亚自助游" /></a>
- </li>
- </ul>
- </div>
- <script type=text/javascript>
- var t = n = 0, count = $(".content a").size();
- $(function(){
- var play = ".play";
- var playText = ".play .text";
- var playNum = ".play .num a";
- var playConcent = ".play .content a";
- $(playConcent + ":not(:first)").hide();
- $(playText).html($(playConcent + ":first").find("img").attr("alt"));
- $(playNum + ":first").addClass("on");
- $(playText).click(function(){window.open($(playConcent + ":first").attr('href'), "_blank")});
- $(playNum).click(function() {
- var i = $(this).text() - 1;
- n = i;
- if (i >= count) return;
- $(playText).html($(playConcent).eq(i).find("img").attr('alt'));
- $(playText).unbind().click(function(){window.open($(playConcent).eq(i).attr('href'), "_blank")})
- $(playConcent).filter(":visible").hide().parent().children().eq(i).fadeIn(1200);
- $(this).removeClass("on").siblings().removeClass("on");
- $(this).removeClass("on2").siblings().removeClass("on2");
- $(this).addClass("on").siblings().addClass("on2");
- });
- t = setInterval("showAuto()", 5000);
- $(play).hover(function(){clearInterval(t)}, function(){t = setInterval("showAuto()", 5000);});
- })
- function showAuto(){
- n = n >= (count - 1) ? 0 : ++n;
- $(".num a").eq(n).trigger('click');
- }
- </script>
- </body>
- </html>
- //该片段来自于http://www.codesnippet.cn/detail/011120136872.html
来源: http://www.codesnippet.cn/detail/011120136872.html