I am creating a react app with createreactapp. I have this if statement that checks for the css display property of a div whose id is step1 as below:
const step1 = document.getElementById("step-1")
if (step1.style.display === 'block') {
console.log("true")
} else {
console.log('false')
}
The CSS style of the div is as follows:
.step-1 {
display: block;
}
However, when I check the console, the if statement returns or console.logs 'false" when it should be 'true'.
The reason I simplified my actual issue this way is because I am trying to potentially hide the div based on the result of the if statement that checks the value of the CSS display property. However, it is not working. Not sure what is going on.
As for the html, it is a simple div with some content:
<div className="step-1" id="step-1">
Some content ....
</div>