如何通过图标值隐藏图像

Has*_*zad 0 html javascript css

大家好,我无法在谷歌上找到我的问题的解决方案.我只是想使用图标值来隐藏图像,如下例所示,我只想隐藏图像中具有icon-value ="1"的图像,它具有.box类

<div class="box">
  <div class="icon"><img src="xyz/smiley.png" icon-value="1" icon-index="0"></div>
  <div class="icon"><img src="xyz/1.png" icon-value="2" icon-index="1"></div>
</div>
Run Code Online (Sandbox Code Playgroud)

Bar*_*mar 5

使用属性选择器.

.box img[icon-value="1"] {
    display: none;
}
Run Code Online (Sandbox Code Playgroud)

  • 这不是一个必要的报价吗?`.box img [icon-value ="1"] {display:none; }` (2认同)