I am having an issue adding a class via jsto an existing html set up. If I inspect, it simply doesnt show up. It doesnt add it. I have it on a delay to ensure everything is done loading. I have also set a console.log
message just to ensure that the function is running and it is.
It does not show in the console as even having been added. Is there something below that is specific to wordpress that is interfering? The example below works on its own but not in its environment.
What am I doing wrong here?
function classadd() {
window.setTimeout(function () {
var ideal = document.getElementById( 'test' )
var parent = document.getElementById('t_options')
if(ideal){
parent.classList.add('black');
console.log('running');
} else {
console.log('uh-oh');
}
},7000);
}
classadd();
.black{background:black!important;}
<div id="t_options" class="some_classes">
<div id="test">
some content
</div>
</div>