<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')) {
Use .is()
to check if an element fills a certain requirement, like such:
if ($(this).find('a div.newchatmessage').is(':visible'))
Or, if you want it more readable:
var element = $(this).find('a div.newchatmessage');
if (element.is(':visible')) {
// Do your thing
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With