I have a few divs that are created using PHP. The anchor within the div always has a HREF, even if it is blank. Basically, I am trying to detect if the HREF is blank. If it
To simply get rid of the 'href' attribute:
$("#myLink[href='']").removeAttr('href');
For multiple targeting, for example the 'style' attribute:
$("#myDiv td, a, p, table, nav, header[style='']").removeAttr('style');
This way, you'll only get rid of the Attribute when it's empty instead of deleting the whole element itself.
A full code example would be:
$('#myDiv table, tr, td, a, p').each(function() {
if ($(this).attr('style') == '') {
$(this).removeAttr('style');
}
})