Below I have a text which is a nested span. I just want to apply opacity to the first word Hello
only. but, the opacity is changing to nested span also i.e STOP
.
How to ignore the dynamic css changes of parent element?
let txt = document.getElementById("txt")
setInterval(() => {
txt.style.opacity = txt.style.opacity == 1 ? 0.2 : 1
},500)
<span id="txt" style="font-size: 50px;">
Hello
<span style="opacity : 1">STOP</span>
</span>