I have a div panel somewhere on my page that should be hidden when the window size gets too small.
Works fine using this css:
#panel {display: block; }
@media (max-width: 1000px) {
#panel { display: none; }
}
There is another rule that displays a button which should make the #panel visible onclick.
#panel {display: block; }
#button {display: none; }
@media (max-width: 1000px) {
#panel { display: none; }
#button {display: block; }
}
The javascript looks like this:
$("#button").click(function() { $("#panel").toggle(); });
there are some other rules as well that make the panel appear friendlier... no need to explain this. The problem is: when you once clicked the button and changed the display state of the panel to on and off again. That means the display:none property was set by the javascript, the panel will not be displayed again when you resize the window > 1000px. The default style of the panel will not be applied, even if you create some rule like @media(min-width: 1000px).. the js seems to have priority.. so what is the best way to combine media queries and js?