简体   繁体   English

显示/隐藏取决于属性

[英]Show/hide depending on attribute

I have a page with many panels on it, each one shown as a thumbnail. 我的页面上有很多面板,每个面板都显示为缩略图。 The data for the thumbnails is extracted from a database, so basically the code is as follows: 缩略图的数据是从数据库中提取的,因此基本上,代码如下:

while ($courant = $sth->fetch()) {
    echo '<div class="panel panel-default inline" big=".$courant->big.">
            <div class=panel-body>
              <a class="box" href="something"><img src="some other thing"/>
              </a>
            </div>
          </div>';
}

The big attribute in the main div is either 0 or 1. How can I show/hide div blocks that have big=0 on a checkbox toggle with JavaScript/jQuery? 主div中的big属性为0或1。如何使用JavaScript / jQuery在复选框中显示/隐藏具有big=0 div块? I know there's a hide() function but I think it only works on classes and ids. 我知道有一个hide()函数,但我认为它仅适用于类和id。

您可以使用属性选择器

$('[big="0"]').hide();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM