Files
journal_com/js/lunbo.js
wangjinlei 6e7ee3dd44 begin
2023-05-18 09:42:12 +08:00

33 lines
1.3 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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元素内的值即1234
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(0).parent().children().eq(i).fadeIn(500);
document.getElementById("banner").style.background = "";
$(this).toggleClass("on");
$(this).siblings().removeAttr("class");
});
t = setInterval("showAuto()", 2000);
$("#banner").hover(function () {
clearInterval(t)
}, function () {
t = setInterval("showAuto()", 2000);
});
})
function showAuto() {
n = n >= (count - 1) ? 0 : ++n;
$("#banner li").eq(n).trigger('click');
}