tab.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. $(function(){
  2. $(".zhzdFir").click(function () {
  3. $(this).toggleClass("now").siblings(".zhzdMenu").slideToggle("fast")
  4. });
  5. })
  6. $(window).bind("scroll",function() {
  7. if ($(document).scrollTop() + $(window).height(768)) {
  8. $('.weiheList').addClass('show');
  9. }
  10. })
  11. $(function(){
  12. $('.caseList .caseListBox').width(990*$('.caseList li').length+'px');
  13. $(".caseContainer .tab a").mouseover(function(){
  14. $(this).addClass('on').siblings().removeClass('on');
  15. var index = $(this).index();
  16. number = index;
  17. var distance = -990*index;
  18. $('.caseContainer .caseListBox').stop().animate({
  19. left:distance
  20. });
  21. });
  22. var auto = 1; //等于1则自动切换,其他任意数字则不自动切换
  23. if(auto ==1){
  24. var number = 0;
  25. var maxNumber = $('.caseContainer .tab a').length;
  26. function autotab(){
  27. number++;
  28. number == maxNumber? number = 0 : number;
  29. $('.caseContainer .tab a:eq('+number+')').addClass('on').siblings().removeClass('on');
  30. var distance = -990*number;
  31. $('.caseContainer .caseListBox').stop().animate({
  32. left:distance
  33. });
  34. }
  35. var tabChange = setInterval(autotab,3000);
  36. //鼠标悬停暂停切换
  37. $('.caseContainer').mouseover(function(){
  38. clearInterval(tabChange);
  39. });
  40. $('.caseContainer').mouseout(function(){
  41. tabChange = setInterval(autotab,3000);
  42. });
  43. }
  44. });