![](/img/trans.png)
[英]SyntaxError: missing ; before statement getting this error in jquery
[英]Jquery - Error message in Firefox developer tools: 'SyntaxError: missing ; before statement'
我在jQuery上苦苦掙扎,看不到這里有什么問題。 有什么建議么?
Firefox開發人員工具中的錯誤消息:'SyntaxError:missing; 在聲明之前” ,第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;
});
});
您的行號似乎已嵌入到代碼中。 這會導致您收到錯誤,並且很可能是從網站復制和粘貼引起的。 行號不應包含在源代碼中,因為它會使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;
});
});
只是一個猜測,如果您進行更改,它會起作用嗎
jQuery(document).ready(function($){
進入
jQuery(document).ready(function(){
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.