English 中文(简体)
j 质量——如何发现所有对应元素是否显示:无
原标题:jQuery - How to find if all matching elements are display:none?

我有一份类似于下文简化编码的碎块清单,我先通过减员设置过滤器(因此,如果你选择在下降中选择一种选择,那么所有不配对的碎块都将显示:无。

<div id="productlist">
   <div class="product book">Title</div>
   <div class="product book">Title</div>
   <div class="product game">Title</div>
   <div class="product movie">Title</div>
   <div class="product game">Title</div>
</div>

然而,如果没有对应措施,我就要发出这样的信息。

如果说的话,是否有办法表明,如果所有与“产品”类相对应的物品(或者如果所有准产品的直接儿童)被安排展示:不,显示信息?

增 编

最佳回答

通过使用<代码>:<>可见 选编和.length来实现。 方法

if ($( .product:visible ).length == 0)
{
    alert( No visible products found. );
}
问题回答

采用<代码>is方法,你的意图非常明确:

if (!$( .product ).is( :visible )) {
  alert( No visible products found. );
}

is(:visible ) Return real if any of the selected divs isprofile, so the if (!$ ( product .is (:visible ) statement will fire only no of the divs areprofile.





相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签