Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
14
rated 0 times [  17] [ 3]  / answers: 1 / hits: 28144  / 11 Years ago, wed, february 12, 2014, 12:00:00

There are 4 of these all the same. I narrowed it down to this line by a process of elimination:



originalImg = $(element).find('.ProductImage a img').attr();


I'm at a bit of a loss of what might be causing this.



Here is my code in full:



$(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){

// This is the problem line.
originalImg = $(element).find('.ProductImage a img').attr();

$(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);
});
});
}

More From » jquery

 Answers
5

You probably meant



originalImg = $(element).find('.ProductImage a img').attr('src');


The attr function isn't designed to be called without arguments.


[#72570] Tuesday, February 11, 2014, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
joep

Total Points: 32
Total Questions: 97
Total Answers: 104

Location: Wales
Member since Thu, Jul 1, 2021
3 Years ago
;