Use getAttribute conditionally