2013-05-04 20 views
1
<script> 
    $(document).ready(function() { 
     // Code to bring each link on to screen and in position 
     $("#link1").animate({ 
      left: '30px', 
      top: '5px' 
     }, 1000); 
     $("#link2").animate({ 
      left: '80px', 
      top: '5px' 
     }, 1400); 
     $("#link3").animate({ 
      left: '130px', 
      top: '5px' 
     }, 1400); 
     $("#link4").animate({ 
      left: '180px', 
      top: '5px' 
     }, 1600); 
     $("#link5").animate({ 
      left: '230px', 
      top: '5px' 
     }, 1800); 

     // Fade in & out on hover 
     $("#link1").hover(function() { 
      $(this).fadeOut(150); 
      $(this).fadeIn(150); 
     }); 

     // Fade in & out on hover 
     $("#link2").hover(function() { 
      $(this).fadeOut(150); 
      $(this).fadeIn(150); 
     }); 

     // Fade in & out on hover 
     $("#link3").hover(function() { 
      $(this).fadeOut(150); 
      $(this).fadeIn(150); 
     }); 

     // Fade in & out on hover 
     $("#link4").hover(function() { 
      $(this).fadeOut(150); 
      $(this).fadeIn(150); 
     }); 

     // Fade in & out on hover 
     $("#link5").hover(function() { 
      $(this).fadeOut(150); 
      $(this).fadeIn(150); 
     }); 

     // Nudge the link when "clicked" 
     $("#link1").mousedown(function() { 
      $(this).css("padding-top", "5px"); 
     }); 

     $("#link1").mouseup(function() { 
      $(this).css("padding-top", "0px"); 
     }); 

     // Nudge the link when "clicked" 
     $("#link2").mousedown(function() { 
      $(this).css("padding-top", "5px"); 
     }); 

     $("#link2").mouseup(function() { 
      $(this).css("padding-top", "0px"); 
     }); 

     // Nudge the link when "clicked" 
     $("#link3").mousedown(function() { 
      $(this).css("padding-top", "5px"); 
     }); 

     $("#link3").mouseup(function() { 
      $(this).css("padding-top", "0px"); 
     }); 

     // Nudge the link when "clicked" 
     $("#link4").mousedown(function() { 
      $(this).css("padding-top", "5px"); 
     }); 

     $("#link4").mouseup(function() { 
      $(this).css("padding-top", "0px"); 
     }); 

     // Nudge the link when "clicked" 
     $("#link5").mousedown(function() { 
      $(this).css("padding-top", "5px"); 
     }); 

     $("#link5").mouseup(function() { 
      $(this).css("padding-top", "0px"); 
     }); 



     // Parallax Scroll 
     $(window).bind('scroll', function (e) { 
      parallaxScroll(); 
     }); 

     function parallaxScroll() { 
       var scrolledY = $(window).scrollTop(); 
       $('#bblogo1').css('top', '-' + ((scrolledY * 0.6)) + 'px'); 
       $('#bblogo2').css('top', '-' + ((scrolledY * 0.5)) + 'px'); 
       $('#bblogo3').css('top', '-' + ((scrolledY * 0.3)) + 'px'); 
       $('#bblogo4').css('top', '-' + ((scrolledY * 0.9)) + 'px'); 
       $('#bblogo5').css('top', '-' + ((scrolledY * 0.6)) + 'px'); 
       $('#bblogo6').css('top', '-' + ((scrolledY * 0.1)) + 'px'); 
       $('#bblogo7').css('top', '-' + ((scrolledY * 0.4)) + 'px'); 

       $('#bbspinner').animate(function(){ 
        $(this).css 
("background","url(images/bblogorender0000.png)"); 
       }); 

     }); 
</script> 

回答

1

这一个你缺少更换你的代码右括号

 $(document).ready(function() 
     // Code to bring each link on to screen and in position 
         { $("#link1").animate({ 
      left: '30px', 
      top: '5px' 
     }, 1000); 
     $("#link2").animate({ 
      left: '80px', 
      top: '5px' 
     }, 1400); 
     $("#link3").animate({ 
      left: '130px', 
      top: '5px' 
     }, 1400); 
     $("#link4").animate({ 
      left: '180px', 
      top: '5px' 
     }, 1600); 
     $("#link5").animate({ 
      left: '230px', 
      top: '5px' 
     }, 1800); 

     // Fade in & out on hover 
     $("#link1").hover(function() { 
      $(this).fadeOut(150); 
      $(this).fadeIn(150); 
     }); 

     // Fade in & out on hover 
     $("#link2").hover(function() { 
      $(this).fadeOut(150); 
      $(this).fadeIn(150); 
     }); 

     // Fade in & out on hover 
     $("#link3").hover(function() { 
      $(this).fadeOut(150); 
      $(this).fadeIn(150); 
     }); 

     // Fade in & out on hover 
     $("#link4").hover(function() { 
      $(this).fadeOut(150); 
      $(this).fadeIn(150); 
     }); 

     // Fade in & out on hover 
     $("#link5").hover(function() { 
      $(this).fadeOut(150); 
      $(this).fadeIn(150); 
     }); 

     // Nudge the link when "clicked" 
     $("#link1").mousedown(function() { 
      $(this).css("padding-top", "5px"); 
     }); 

     $("#link1").mouseup(function() { 
      $(this).css("padding-top", "0px"); 
     }); 

     // Nudge the link when "clicked" 
     $("#link2").mousedown(function() { 
      $(this).css("padding-top", "5px"); 
     }); 

     $("#link2").mouseup(function() { 
      $(this).css("padding-top", "0px"); 
     }); 

     // Nudge the link when "clicked" 
     $("#link3").mousedown(function() { 
      $(this).css("padding-top", "5px"); 
     }); 

     $("#link3").mouseup(function() { 
      $(this).css("padding-top", "0px"); 
     }); 

     // Nudge the link when "clicked" 
     $("#link4").mousedown(function() { 
      $(this).css("padding-top", "5px"); 
     }); 

     $("#link4").mouseup(function() { 
      $(this).css("padding-top", "0px"); 
     }); 

     // Nudge the link when "clicked" 
     $("#link5").mousedown(function() { 
      $(this).css("padding-top", "5px"); 
     }); 

     $("#link5").mouseup(function() { 
      $(this).css("padding-top", "0px"); 
     }); 



     // Parallax Scroll 
     $(window).bind('scroll', function (e) { 
      parallaxScroll(); 
     }); 

     function parallaxScroll() { 
       var scrolledY = $(window).scrollTop(); 
       $('#bblogo1').css('top', '-' + ((scrolledY * 0.6)) + 'px'); 
       $('#bblogo2').css('top', '-' + ((scrolledY * 0.5)) + 'px'); 
       $('#bblogo3').css('top', '-' + ((scrolledY * 0.3)) + 'px'); 
       $('#bblogo4').css('top', '-' + ((scrolledY * 0.9)) + 'px'); 
       $('#bblogo5').css('top', '-' + ((scrolledY * 0.6)) + 'px'); 
       $('#bblogo6').css('top', '-' + ((scrolledY * 0.1)) + 'px'); 
       $('#bblogo7').css('top', '-' + ((scrolledY * 0.4)) + 'px'); 

       $('#bbspinner').animate(function(){ 
        $(this).css 
("background","url(images/bblogorender0000.png)"); 
       }); 
     } 
         }); 

您可以检查这里http://jsfiddle.net/

+1

谢谢,缺少}关闭视差滚动解决了这个问题。 – coltdorsey 2013-05-04 08:45:06

2

就在年底,在parallaxScroll底部,则需要前});你有没有把一个}。该});关闭文档ready叫你开始在开始的时候,所以你需要它,但你需要首先关闭parallaxScroll功能:

function parallaxScroll() { 
      var scrolledY = $(window).scrollTop(); 
      $('#bblogo1').css('top', '-' + ((scrolledY * 0.6)) + 'px'); 
      $('#bblogo2').css('top', '-' + ((scrolledY * 0.5)) + 'px'); 
      $('#bblogo3').css('top', '-' + ((scrolledY * 0.3)) + 'px'); 
      $('#bblogo4').css('top', '-' + ((scrolledY * 0.9)) + 'px'); 
      $('#bblogo5').css('top', '-' + ((scrolledY * 0.6)) + 'px'); 
      $('#bblogo6').css('top', '-' + ((scrolledY * 0.1)) + 'px'); 
      $('#bblogo7').css('top', '-' + ((scrolledY * 0.4)) + 'px'); 

      $('#bbspinner').animate(function(){ 
       $(this).css("background","url(images/bblogorender0000.png)"); 
      }); 
    } // <==== Here 
}); 
2

JavaScript验证除了上面的答案从ohgo dwhy,你没有关闭你的document.ready。当你当前的最后一行是:

所以,你需要关闭如上的视差滚动,但你也需要与宣称的功能

}); 

之前,关闭您的document.ready。

2

你可以用})结束文档准备;但它会在一些浏览器中自动验证,

我建议在IE上测试你的应用程序,这样你就会知道语法错误。

相关问题