2016-07-01 20 views
0

早上好,添加數量Prestashop按鈕無法讀取屬性'top',爲什麼?

我有一個添加數量按鈕(Prestashop),每次我點擊它的作品,但缺貨時它需要出現一個缺貨的錯誤信息。

這個Js有什麼問題?

錯誤日誌安裝在後下

$(document).ready(function(){ 
$('a').on('click', function(){ 
    var GetaName = $(this).attr('href').split('#'); 
    $('html,body').animate({scrollTop : $('a[name="'+GetaName[1]+'"]').offset().top},1000); 
}); 
}); 

error-log

+0

嗨Sasha,你可以作爲純文本發佈錯誤?通過編輯問題 –

回答

0

在TE截圖錯誤說$('a[name="'+GetaName[1]+'"]').offset()不存在。

這意味着$('a[name="'+GetaName[1]+'"]')返回null

在檢查偏移之前,您應該檢查$('a[name="'+GetaName[1]+'"]')是否存在。

相關問題