其中有4个都是一样的。我通过一个审判过程将其描述为这一行:
originalImg = $(element).find('.ProductImage a img').attr();
我有点失去可能导致这种情况的原因。
$(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);
});
});
答案 0 :(得分:12)
你可能意味着
originalImg = $(element).find('.ProductImage a img').attr('src');
attr
函数不能在没有参数的情况下调用。