jQuery(function () { //经过填加相应的CLASS jQuery(".unit").find("li").mouseover(function () { jQuery(this).addClass("hover").siblings().removeClass("hover"); }); }); //图片+文字轮播 function Switch(switchImg, switchText) { var times = 3000; //轮播间隔时间 var size = jQuery(switchImg).children().size(); jQuery(switchImg).children().eq(0).show(); jQuery(switchText).children().eq(0).addClass('focus') jQuery(switchText).children().mouseover(function () { jQuery(this).addClass('focus').siblings().removeClass('focus'); var index = $(this).index(); i = index; jQuery(switchImg).children().eq(index).stop(true).fadeIn(300).siblings().stop(true).hide(); }); var i = 0; var time = setInterval(move, times); function move() { i++; if (i == size) { i = 0; } jQuery(switchText).children().eq(i).addClass('focus').siblings().removeClass('focus'); jQuery(switchImg).children().eq(i).fadeIn(300).siblings().hide(); } jQuery(switchImg).parent().hover(function () { clearInterval(time); }, function () { time = setInterval(move, times); }); } //模似select function toSelect(selectTop, selectBot) { jQuery(selectTop).click(function (event) { event.stopPropagation(); if (jQuery(selectBot).hide()) { jQuery(selectBot).show(); } }); jQuery(selectBot).children().click(function (event) { event.stopPropagation(); jQuery(selectTop).val($(this).html()); jQuery(selectBot).hide(); }); jQuery(document).click(function (event) { jQuery(selectBot).hide(); }); } //选项卡 function tab(topObject, botObject) { var $div_a = $(topObject).find("a"); jQuery(botObject).eq(0).show(); jQuerydiv_a.mouseover(function () { jQuery(this).addClass("focus").siblings().removeClass("focus"); var index = $div_a.index(this); jQuery(botObject).eq(index).show().siblings(botObject).hide(); }); } //行业评选轮播 function carousel(obj) { var This = $(obj); var sWidth = $(This).width(), len = $(This).find('ul li').length, index = 0, Timer; var liWidth = 100 / len; jQuery(This).find('li').width(liWidth + "%"); // btn event 数字和切换 var btn = "
/
"; jQuery(This).append(btn); jQuery('.number b').html(1); jQuery('.number em').html(len); jQuery(This).find('.tabRight').click(function () { index++; if (index == len) { index = 0; } jQuery('.number b').html(index + 1); //点击切换数字跟着变 Tony(index); }); jQuery(This).find('.tabLeft').click(function () { index--; if (index == -1) { index = len - 1; } jQuery('.number b').html(index + 1); Tony(index); }); // start setInterval jQuery(This).find('ul').css("width", sWidth * (len)); jQuery(This).hover(function () { clearInterval(Timer); }, function () { Timer = setInterval(function () { Tony(index); index++; jQuery('.number b').html(index); //数字跟着滚动变 if (len == index) { index = 0; } }, 2000) }).trigger("mouseleave"); function Tony(index) { var new_width = -index * sWidth; jQuery(This).find('ul').stop(true, false).animate({ 'left': new_width }, 500); }; } function tab2(topObject, topSubObject, styleName, botObject, topSubObject2) { var aLink = document.getElementById(topObject).getElementsByTagName(topSubObject); var oLi = document.getElementById(botObject).getElementsByTagName(topSubObject2); oLi[0].style.display = "block"; for (i = 0; i < aLink.length; i++) { aLink[i].index = i; aLink[i].onmouseover = function () { var index = this.index; for (i = 0; i < aLink.length; i++) { aLink[i].className = ""; oLi[i].style.display = "none"; } this.className = styleName; oLi[index].style.display = "block"; } } }