How to change style css value using javascript?
If you change the css style using javascript, then the style will be added to the general css style. See image below. Question: how to add or change style in media screen?
How to change style css value using javascript?
If you change the css style using javascript, then the style will be added to the general css style. See image below. Question: how to add or change style in media screen?
Try to give it !important
to be
el.style.setProperty("display", "block !important")
First, set the display to a variable:
.div2 {
--display: none;
display: var(--display);
}
el.style.setProperty("--display", "block");
You need to check the device width.
const width = window.innerWidth || document.documentElement.clientWidth ||document.body.clientWidth;
(width > 500) ? el.style.setProperty("display", "block !important") : el.style.setProperty("display", "none !important")