<h4>Красим коды в разные цвета :</h4>
<div>
<p><span>(343)</span> 12345</p>
<p><span>(344)</span> 12345</p>
<p><span>(355)</span> 12345</p>
<p><span>(365)</span> 12345</p>
<p><span>(3333)</span> 12345</p>
<p><span>(1232)</span> 12345</p>
</div>
div {
padding: 16px;
background-color: black;
}
p {
font-size: 16px;
color: white;
margin:5px;
}
$(document).ready(function() {
var colors = {
"(343)": "red",
"(344)": "orange",
"(365)": "green",
"(3333)": "yellow",
"(1232)": "grey"
};
$("span").each(function() {
$(this).css({ color: colors[$(this).html()] || "white" });
});
});
This Pen doesn't use any external CSS resources.