. plusDifference {
color: #369c38;
}
. minusDifference{
color: #c7291e;
}
const MCITEMDIFFERENCE = document.querySelectorAll('.mc__span');
MCITEMDIFFERENCE.forEach((element)=>{
if (element.innerHTML.startsWith("+")) {
element.classList.add("plusDifference"));
}
if (element.innerHTML.startsWith("-") {
element.classList.add("minusDifference");
}
})
<div class="mc-block">
<div class="mc-item">
<span class="mc__span">+10%</span>
</div>
<div class="mc-item">
<span class="mc__span">-10%</span>
</div>
<div class="mc-item">
<span class="mc__span">-10%</span>
</div>
<div class="mc-item">
<span class="mc__span">+10%</span>
</div>
</div>