Atif Azad
Atif Azad

Reputation: 737

how to hide image by its icon-value

hi everyone i cant find the solution for my question on google. i just want to hide the images using there icon-value like in the below example i just want to hide the image which have icon-value="1" in the div which have .box class

<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>

Upvotes: 0

Views: 98

Answers (3)

Sarath
Sarath

Reputation: 608

using css try following

.box .icon img[icon-value="1"] {
        display: none;
    }

or if you are using jquery you can try this also

$(".box img[icon-value=1]").hide();

Upvotes: 2

Barmar
Barmar

Reputation: 782785

use an attribute selector.

.box img[icon-value="1"] {
    display: none;
}

Upvotes: 5

Vikram Deshmukh
Vikram Deshmukh

Reputation: 15736

CSS solution:

.box img[icon-value="1"] {
    display: none;
}

Demo

PS: Notice the value in quotes. I don't think CSS attribute selectors will work if the value is not specified in quotes

jQuery solution:

$(".box img[icon-value=1]").css("display", "none");

Demo

Upvotes: 2

Related Questions