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内部生成未捕获错误的一般规则,请确定您使用的版本。 –