
HTML
<div id="banner">
<div id="banner_bg"></div>
<!--标题背景-->
<div id="banner_info"></div>
<!--标题-->
<ul>
<li class="on">1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
<div id="banner_list">
<a href="#" target="_blank"><img src="images/p1.jpg" title="智慧小屋1" alt="智慧小屋1"/></a>
<a href="#" target="_blank"><img src="images/p2.jpg" title="智慧小屋2" alt="智慧小屋2"/></a>
<a href="#" target="_blank"><img src="images/p3.jpg" title="智慧小屋3" alt="智慧小屋3"/></a>
<a href="#" target="_blank"><img src="images/p1.jpg" title="智慧小屋4" alt="智慧小屋4"/></a>
</div>
</div> jQuery
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元素内的值,即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);
document.getElementById("banner").style.background = "";
$(this).toggleClass("on");
$(this).siblings().removeAttr("class");
});
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');
} *
回帖描述:*
链接类型:*
下载链接:*
描述:*
回帖描述:*
链接类型:*
阅读权限:*
下载链接:



聚优部落技术论坛 © 版权所有 鲁ICP备15007479号-6
Copyright(C)web.com, All Rights Reserved.
