How do I add/remove class on button click?

How do I add/remove class on button click?

I'm sure these are some absolute beginner questions but I just dont know how.

Question 1:

I have a button on my page, lets just pretend this is it:

<div class="navappear">Open Navigation</div>

When you click that button, I want it to remove the "hidden" class or add it, depending on which state it is in.

<div id="extranav" class="hidden"></div>

How do I do this?

Question 2:

If I also have another div, lets say:

<div id="background" class="nav-open"></div>

Can I have that same button also change the class on another element at the same time?



Thanks,
Jordan