<p>I need to figure out what div is visible out of four possible divs using jQuery.  Only one of those div's will be visible at any given time.</p>

<p>This is what I have that works so far:</p>

<pre><code>$("#FeatureImage1:visible, #FeatureImage2:visible, #FeatureImage3:visible, #FeatureImage4:visible").attr("id");
</code></pre>

<p>Is there a way to refactor this?  Is there an easier way to figure this out?</p>

[{'answer_id': 61500, 'author': 'Gilean', 'author_id': 6305, 'author_profile': 'https://Stackoverflow.com/users/6305', 'pm_score': 5, 'selected': True, 'text': '<p>Assign the same class to each div then:</p>\n\n<pre><code>$("div.myClass:visible").attr("id");\n</code></pre>\n'}, {'answer_id': 64390, 'author': 'Jim', 'author_id': 8427, 'author_profile': 'https://Stackoverflow.com/users/8427', 'pm_score': 1, 'selected': False, 'text': '<p>When applicable, it\'s better to use contextual selectors rather than add spurious classes.  For instance, if the <code>&lt;div&gt;</code> elements are the only children of an element with <code>id="foo"</code>, then using <code>$("#foo &gt; div:visible").attr("id")</code> would better reflect the purpose of the code.</p>\n'}]
['https://Stackoverflow.com/questions/61486', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/648/']