jQuery如果可见

前端之家收集整理的这篇文章主要介绍了jQuery如果可见前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
<div id="chatCenterMembers">
   <div class="chatmember">
       <a title="Blah Blah Blah">
          <div class="newchatmessage" style="display: block;"></div>

如何在if语句中捕获可见的div?

我有$(这)设置为< div class =“chatmember”> – 从顶部的第二行.

我一直在下面工作,但现在运气到目前为止.

if($(this+' a div.newchatmessage').filter(":visible")) {

以上只是掉出来

我也试过下面,它也不工作

if ($(this + 'a div.newchatmessage').is(':visible')) {

解决方法

.is()

有关此方法的任何详细信息,只需向下滚动一下…有一堆示例!

编辑(感谢@Wesley Murch的提示):如果这不行,你的选择器可能是错误的… $(这个’div.newchatmessage’)看起来很奇怪,它可能是$(‘一个div.newchatmessage’,这个)或$(‘a div.newchatmessage’,$(this))取决于这是一个jQuery变量

猜你在找的jQuery相关文章