This scripts works in all browser’s but IE7..
Overview: I got a page of products (li.prod). Each product has an image (li.prod div.mainpic img). That image has a title attribute which I am using to add a class of the same name to the appended . Then all the brands are shown automatically by using css.
$('li.prod .mainpic').each (function() {
var jThis = $(this);
var mainImages = jThis.find('img');
jThis.prepend('<div class="prod-logo"></div>');
var targList = jThis.find('div.prod-logo');
mainImages.each(function() {
newClass = $(this).attr('title');
targList.addClass (newClass);
});
});
Anyone know of a solution that will work for all browers?
The problem was not the code. I just needed to declare the variables.