显示/隐藏取决于属性

时间:2014-09-24 16:54:24

标签: javascript jquery html

我有一个页面上有许多面板,每个面板都显示为缩略图。缩略图的数据是从数据库中提取的,所以基本上代码如下:

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>';
}

主div中的big属性为0或1.如何在复选框上使用JavaScript / jQuery显示/隐藏具有big=0的div块?我知道有一个hide()函数,但我认为它只适用于类和ID。

1 个答案:

答案 0 :(得分:1)

您可以使用attribute selector

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