Home > Enterprise >  Make a button hidden when body has class name "dark"
Make a button hidden when body has class name "dark"

Time:10-05

I have two buttons one makes the theme dark and the other one makes the theme light I want the dark button hides when body has class name "dark" and the light button be hidden when body has class name "light".

Thank you.

CodePudding user response:

You would do this using CSS. Let's say you have buttons like this in your HTML:

<body >
  <button >Light</button>
  <button >Dark</button>
</body>

The CSS to make the appropriate buttons hidden depending on body class is this:

body.light button.btn-dark {
  display: none;
}

body.dark button.btn-light {
  display: none;
}
  • Related