I have a sentence with a highlighted word:
I'm trying to make it so the class="special"
is visible and the rest of the class="sentence"
appears around it.
After a few seconds, I'm triggering this:
setTimeout(() => {
document.getElementById("sentence-1").className += " fadeIn";
}, 2000)
.sentence {
opacity: 0;
}
.special {
opacity: 1;
}
.fadeIn{
opacity: 1;
transition: opacity 2s 2s;
}
<span id="sentence-1" class="sentence">This is the special <span id="special-1" class="special">word</span>, cool huh?</span>
Which in my mind says set the opacity of .sentence
to 0 and the opacity of .special
to 1 then fade in sentence when the javascript is triggered...
Instead, the whole thing fade in, and I can't make .special
visible all the time.
Edits: I have access to either .class or #id for the parent and child element if that helps...