$(document).ready(function(){ var oul = $('.accmin ul'); $('.tpic li img').hover(function() { var osrc = $(this).attr('src').split('/')[4].split('.')[0]; $(this).attr('src','/dyxzfw/xhtml/images/'+osrc+'h.png'); $(this).next('span').css('z-index','999'); }, function() { var osrc = $(this).attr('src').split('/')[4].split('.')[0].split('h')[0]; $(this).attr('src','/dyxzfw/xhtml/images/'+osrc+'.png'); $(this).next('span').css('z-index','0'); }); function Animated(){ /*this.ona = $('.navs ul li a');*/ } Animated.prototype = { fanhdb:function(){ var t = $(document).scrollTop(); var n; var r; var i = !0; $(window).scroll(function() { var t = $(document).scrollTop(); if (t > 300) { $('#rocket-to-top').css("display", 'block'); $('#rocket-to-top').click(function(){ $(this).css({ "margin-top": "-125px", display: "none" }); }); } else { $('#rocket-to-top').css("display", 'none'); } }), $('#rocket-to-top').hover(function() { $(".level-2").stop(!0).animate({ opacity: 1, }) }, function() { $(".level-2").stop(!0).animate({ opacity: 0, }) }), $(".level-3").click(function() { function t() { var t = $('#rocket-to-top').css("background-position"); if ($('#rocket-to-top').css("display") == "none" || i == 0) { clearInterval(n), $('#rocket-to-top').css("background-position", "0px 0px"); return } switch (t){ case "0px 0px": $('#rocket-to-top').css("background-position", "-298px 0px"); break; case "-298px 0px": $('#rocket-to-top').css("background-position", "-447px 0px"); break; case "-447px 0px": $('#rocket-to-top').css("background-position", "-596px 0px"); break; case "-596px 0px": $('#rocket-to-top').css("background-position", "-745px 0px"); break; case "-745px 0px": $('#rocket-to-top').css("background-position", "-298px 0px"); } } if (!i) return; n = setInterval(t, 50), $("html,body").animate({scrollTop: 0,},"slow"); }); }, location:function(){ this.ona.click(function(){ var navtxt= $(this).text(); $(this).addClass('on'); $(this).parent().siblings().children().removeClass('on'); $('.positionl').each(function(){ if (navtxt == $(this).text()) { var pos = $(this).offset().top-68; console.log(pos); $("html,body").stop().animate({ scrollTop: pos, }, 1000); } }); }); }, shanzhuan:function(){ /* $(".spots li:nth-child(even)").addClass("fr"); $(".spots li:nth-child(odd)").addClass("fl");*/ /*$('.sights .accmin ul .tsxst .d').css({'margin-left': -$('.sights .accmin ul .tsxst .d').width()/2}); $('.sights .accmin ul .tsxst .d').css({'margin-left': -$('.sights .accmin ul .tsxst .d').width()/2});*/ /*window.ref = setInterval(function(){ $('.sights .accmin ul .tsxst .d').each(function() { //console.log($(this).width()+$(this).index()); $(this).css({'margin-left': -$(this).width()/2}); }); clearInterval(window.ref); },100); window.refa = setInterval(function(){ $('.sights .accmin ul .tsxst .d').each(function() { //console.log($(this).width()+$(this).index()); $(this).css({'margin-left': -$(this).width()/2}); }); clearInterval(window.refa); },100);*/ $('.sights .accmin ul .tsxst .d').each(function() { //console.log($(this).width()+$(this).index()); $(this).css({'margin-left': -$(this).width()/2}); }); $('.sights .accmin ul .tsxst .d').each(function() { //console.log($(this).width()+$(this).index()); $(this).css({'margin-left': -$(this).width()/2}); }); } } var location = new Animated(); //location.location(); //location.fhseinment(); location.shanzhuan(); location.fanhdb(); });