To see whether an attribute on an html or xml element is actually defined / present, you can do the following:
if ($('#bla').attr('myattr') !== undefined) { // attribute exists } else { // attribute does not exist }
if(typeof $('#bla').attr('myattr') != 'undefined') { ...