<div id="chatCenterMembers">
<div class="chatmember">
<a title="Blah Blah Blah">
<div class="newchatmessage" style="display: block;"></div>
How can I capture the visible div in an if statement?
I have $(this) set to <div class="chatmember"> – second line from the top.
I’ve been working with below but had now luck so far.
if($(this+' a div.newchatmessage').filter(":visible")) {
Above just drops out…
I’ve also tried below and it doesn’t work either
if ($(this + 'a div.newchatmessage').is(':visible')) {
.is()for any detailed information on this method, just scroll down a bit … there’s a bunch of examples!
edit (thanks for the hint @Wesley Murch):
if this does not work, your selector might be wrong …
$(this+' a div.newchatmessage')looks quite strange … it might rather be$('a div.newchatmessage', this)or$('a div.newchatmessage', $(this))depending onthisbeing a jQuery-variable or not