So I have this jQuery function:
$('ul li').click(function () {
var title = $('img', this).attr("title");
$("a.songtitle span").text(title);
var artist = $('img', this).attr("artist");
$("a.songartist span").text(artist);
var artwork = $('img', this).attr('src');
artwork = artwork.replace('src');
$('img.a').attr('src', artwork);
$(this).addClass('playing').siblings().removeClass('playing');
audio.load($('a#tunes', this).attr('data-src'));
audio.play();
});
So, when clicked, it gets album artwork from an img src attribute and replaces it with the current. As you can see in this example, it's only working the first time, and then no longer replaces the img src attribute when you click on "Next". Why is this happening? If someone can help that would be greatly appreciated. Thank you!
This line
is replacing the
src
attribute value for all images with classa
.Also, you're missing the second argument to
replace()
on this linelucky for you, it's not doing anything unless the string "src" appears in the image URL.