0

I'm trying to make my main div's "display:'none'" after a button press. But it's returning an error which appears to state that the getElementByID field is null.

Here's the code snippets that I'm working with:

<div className="content" style={Style}>
        <ButtonGroup variant="contained" color="primary" size="large">
        <Button onClick={() => {this.loadtrainingresources()}}>TRAINING RESOURCES</Button>
        </ButtonGroup>
</div>

loadtrainingresources = () =>{
document.getElementById("content").display = "none";
}

Error Output

1 Answers1

0

You forgot style

document.getElementById("content").style.display = "none";

https://www.w3schools.com/jsref/prop_style_display.asp

Lundstromski
  • 1,197
  • 2
  • 8
  • 17