I have a page that hides a div when the screen is small, showing another div with a clickable + to expand the hidden div.
@media screen and (max-width: 1230px) {
#details_Title {
display: none;
}
#details_Details {
display: inline; // THIS DOES NOT WORK AFTER JQUERY SLIDEUP
}
}
@media screen and (max-width: 990px) {
#details_Title {
display: inline;
}
#details_Details {
display: none;
}
}
The HTML
<div id="details_Title" onclick="showDetails()">
<b>Details</b>
<img id="imgPlusMinus" src="images/plus.png"/>
</div>
<div id="details_Details">
.... the details
</div>
JS
function showDetails() {
var img=document.getElementById('imgPlusMinus').src;
if (img.indexOf('plus.png')!=-1) {
document.getElementById('imgPlusMinus').src ='images/minus.png';
$("#details_Details").slideDown();
}
else {
document.getElementById('imgPlusMinus').src='images/plus.png';
$("#details_Details").slideUp();
}
}
Make the screen small, the divs show and hide correctly, click the + and the div details_Details expands as expected.
The problem is that if you close it and jQuery slides up the div details_Details, display: none is applied at the element level and the display: inline from the media query does not get applied. How do I get around this? Can I remove/overwrite the element level style from the media query?