我想仅在单击按钮时以移动格式显示隐藏内容吗?

时间:2018-08-16 06:47:57

标签: jquery html css

我有一个过滤器div,它在移动格式中不可见,但在桌面中可见。现在,我只想单击一下即可在移动设备上显示它,因为我想在移动设备上保存最大的面积?

<html>
<head>
<style>
.bookfilter-container {
    display:block;
}
@media (max-width: 900px) {
.bookfilter-container {
display:none;
                     }
}

</style>
</head>
<body>
   <div class="bookfilter-container" id="bookfilter">
      my Filter goas here.
   </div>
</bod>
<html>

1 个答案:

答案 0 :(得分:0)

<html>
<head>
<style>
.bookfilter-container {
    display:block;
}
@media (max-width: 900px) {
.bookfilter-container {
display:none;
                     }
}

</style>
</head>
<body>
<a href="javascript:void(0)" class="click_on">Click</a>
   <div class="bookfilter-container" id="bookfilter">
      my Filter goas here.
   </div>
</bod>
<html>
var windowWidth = $(window).width();
if(windowWidth <= 900px){
$(".click_on").on('click', function(){
    $(".bookfilter-container").css("display","block");
});
}