As you see I have more than one .box
div and my .box
div has data-item-color
attribute I need to get data-item-color
value to change my .box
css properties (.line,.tinyline,h6,p), shortly:
if my data-item-color
has red
value than make my .line
,h6
,p
to red which is inside of .box
div
and demo link
$(document).ready(function() {
});
h6,
p,
span {
padding: 0;
margin: 0;
}
.box {
width: 200px;
padding: 20px;
float: left;
margin: 10px;
}
.line:before {
content: "";
width: 100%;
height: 5px;
background: #000;
display: block;
}
.tinyline:after {
content: "";
width: 100%;
height: 2px;
background: #000;
display: block;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="box" data-item-color="red">
<span class="line"></span>
<h6>RED</h6>
<p>red text...
<span class="tinyline"></span>
</p>
</div>
<div class="box" data-item-color="blue">
<span class="line"></span>
<h6>BLUE</h6>
<p>Blue text..
<span class="tinyline"></span>
</p>
</div>