1
其中有4個完全相同。Jquery未捕獲TypeError:無法讀取未定義的屬性'nodeType'
originalImg = $(element).find('.ProductImage a img').attr();
我在一點點什麼可能導致這樣的損失:我通過elimanation的過程narrawod下來到這條線。
$(function(){
$('.SubCategoryList li').each(function(index, element) {
$(element).append('<div class="ProductListWrapper"></div>')
var subcategory_link = $(element).find('a').attr('href');
$(element).find('.ProductListWrapper').load(subcategory_link + ' #CategoryContent ul.ProductList', productHovers);
});
});
function productHovers(){
$('.SubCategoryList .ProductList li').each(function(index, element){
originalImg = $(element).find('.ProductImage a img').attr(); // This is the problem line.
$(element).mouseover(function(){
var link = $(this).find(".ProductImage a").attr('href');
$.get(link,function(data,status){
var tinyImg = $(data).find('.ImageCarouselBox ul li:nth-child(1) img').attr('src');
var imageSRC = tinyImg.replace('.60.60.jpg','.200.200.jpg');
$(element).find('.ProductImage a img').attr('src',imageSRC);
});
});
$(element).mouseleave(function(){
$(element).find('.ProductImage a img').attr('src',originalImg);
});
});
作爲在jQuery內部生成未捕獲錯誤的一般規則,請確定您使用的版本。 –