You can use :visible filter selector for this.
$('.ContentDivs:visible').........
Update:
A simpler approach would be to provide each of your links with a rel attribute with the same value as the div and class id, for example:
<a rel="Link1" class="link" href="#">Link1</a> <a rel="Link2" class="link" href="#">Link1</a>
And divs:
<div id="Link1"> Div1 </div> <div id="Link2"> Div2 </div>
And then all you need is to get the link with the button pressed and show / hide the corresponding div:
$('a.link').click(function(){ var rel = $(this).attr('rel'); if ($('div#' + rel).is(':visible')) { $('div#' + rel).fadeOut('fast'); } else { $('div#' + rel).fadeIn('fast'); } return false; });
source share