function picroll(picParent,picIndex,picImgList,activity,type,hasTitle,titleClass){ var len = picImgList.find("li").length; var index = 0; //图片序号 var adTimer; picIndex.find("li").mouseover(function() { index = picIndex.find("li").index(this); //获取鼠标悬浮 li 的index showImg(index); }).eq(0).mouseover(); //滑入停止动画,滑出开始动画. function showImg(index) { var adWidth = picImgList.find("li:first").width(); if(type=="margin-right"){ picImgList.stop(true, false).animate({ "margin-right": -adWidth * index + "px" //改变 marginTop 属性的值达到轮播的效果 }, 1000); }else{ picImgList.stop(true, false).animate({ "margin-left": -adWidth * index + "px" //改变 marginTop 属性的值达到轮播的效果 }, 1000); } picIndex.find("li").removeClass(activity); picIndex.find("li").eq(index).addClass(activity); $("."+titleClass).hide(); $("."+titleClass).eq(index).show(); } picParent.hover(function() { clearInterval(adTimer); }, function() { adTimer = setInterval(function() { showImg(index) index++; if (index == len) { //最后一张图片之后,转到第一张 index = 0; } }, 3000); }).trigger("mouseleave"); } function infoRoll(next,last,infoList){ infoList.eq(0).show(); var len = infoList.length; var index = 0; //信息序号 var adTimer; //滑入停止动画,滑出开始动画. function showInfo(index) { infoList.hide(); infoList.eq(index).show(1000); } next.click(function() { index++; if (index == len) { //最后一张图片之后,转到第一张 index = 0; } showInfo(index) }); last.click(function() { if(index==0){ index=len-1; }else{ index--; } showInfo(index); }); } $(document).ready(function(e) { picroll($("#pic_roll"),$("#pic_roll_index"),$("#pic_roll_imgList"),"pic_roll_active","margin-left",true,"pic_roll_bottom_text"); picroll($("#pic_roll2"),$("#pic_roll2_index"),$("#pic_roll2_imgList"),"pic_roll2_active","margin-left"); $('#body_div1_left_menu>li').click(function () { var index = $(this).index(); $(this).find("div").addClass("body_div1_left_menu_active"); $(this).siblings('li').find("div").removeClass('body_div1_left_menu_active'); $('.body_div1_tab_show').eq(index).show(1000).siblings('.body_div1_tab_show').hide(); }); infoRoll($(".newst_2"),$(".newst_3"),$(".body_div1_right_text")); });