This is exactly the kind of behaviour a class is meant for - duplicating logic over a set of elements. It's possible to use an id
attribute selector in jQuery although these are relatively slow and should be used as a last resort.
All you need to do is give the class to your elements and amend your code like this:
if ($('.fail').is(':visible')) {
alert('at least one element is visible');
}