Check if attribute exists
if ($('#A').attr('myattr') !== undefined) { // attribute exists } else { // attribute does not exist }