detect if an image is present, do something else if not
Hello, I have some code which switches the background image of a link using the rel attribute's info. However, the rel attribute will always have something in it but an image may not always be there. Is there a way to check for an image and if not do cancel the process?
$("#words li a").each(function() {
var bgimage = $(this).attr("rel");
$(this).css("background-image", "url(/news/ynews/w/thumb/" + bgimage + ".jpg)");
});