2014-09-01 42 views
0

我與jQuery鬥爭,我看不出什麼問題在這裏。有什麼建議麼?Jquery - Firefox開發人員工具中的錯誤消息:'SyntaxError:missing;之前的聲明'

Error message in Firefox developer tools: 'SyntaxError: missing ; before statement', in line 1.

jQuery(document).ready(function($){ 
    $(window).scroll(function(){ 
     if ($(this).scrollTop() < 200) { 
      $('#smoothup') .fadeOut(); 
     } else { 
      $('#smoothup') .fadeIn(); 
     } 
    }); 
    $('#smoothup').on('click', function(){ 
     $('html, body').animate({scrollTop:0}, 'fast'); 
     return false; 
     }); 
}); 
+0

是在你的代碼的行號最初,還是你張貼的行號,以證明它的工作,其一個是'1號線'? – therealrootuser 2014-09-01 22:48:35

回答

0

看來你的行號嵌入代碼。這會導致您收到的錯誤,很可能來自網站的複製和粘貼。行號不應包含在源代碼中,因爲它會導致JavaScript解析器將它們解釋爲代碼語句,從而產生錯誤。像這樣刪除它們。

jQuery(document).ready(function($){ 
    $(window).scroll(function(){ 
     if ($(this).scrollTop() < 200) { 
      $('#smoothup') .fadeOut(); 
     } else { 
      $('#smoothup') .fadeIn(); 
     } 
    }); 
    $('#smoothup').on('click', function(){ 
     $('html, body').animate({scrollTop:0}, 'fast'); 
     return false; 
     }); 
}); 
0

只是一個猜測,會如果你改變

jQuery(document).ready(function($){ 

jQuery(document).ready(function(){ 
相關問題