With jquery you can do:
$('a:has(img)').css('background-color', 'transparent');
With straight up javascript I would try:
// Check not only immediate children but all descendants recursively
function hasImgChild(oElement) {
if (oElement.tagName == 'img') { return true; }
for (var n=0; n<oElement.childNodes.length; n++) {
if (hasImgChild(oElements.childNodes[n])) { return true; }
}
return false;
}
// Get all <a> tag dom references
var aLinks = document.getElementsByTagName('a');
// Loop through all <a> tags and if any of them
// Have <img> descendants, set background-color css property to 'transparent'
for (var n=0; n<aLinks.length; n++) {
if (hasImgChild(aLinks[n])) {
aLinks[n].style.backgroundColor = 'transparent';
}
}