I am trying to animate $("#somediv").slideDown("slow");
and $("#somediv").slideUp("slow");
But when it slideUp() and you make the screen bigger, it keeps hidden.
Example:
function toggle() {
$("#somediv").slideUp("2000");
}
/* Desktop */
@media only screen and (min-width: 1px) {
#somediv {
display: block;
/* More styling */
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><a href="javascript:void(0);" onclick="toggle()">TOGGLE</a><div id="somediv">Div</div>
I've searched on the internet but couldn't find a solution.
Is this possible?
Thanks for helping!
SOLVED For the people with the same problem:
function toggle() {
if($("#somediv").css('display') == "none") {
$("#somediv").slideDown("2000");
}else {
$("#somediv").slideUp("2000");
}
}
$(window).on("resize",function(){
if (window.matchMedia('(min-width: 800px)').matches) {
$("#somediv").show();
}else {
$("#somediv").hide();
}
});