0

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>

3 Answers 3

5

use an attribute selector.

.box img[icon-value="1"] {
    display: none;
}
Sign up to request clarification or add additional context in comments.

2 Comments

Isn't a quote needed for this to work? .box img[icon-value="1"] {display: none; }
Apparently you're right. I'm used to jQuery, which is less strict than CSS.
2

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

Comments

2

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();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.