简体   繁体   English

滑动DIV容器

[英]Sliding up DIV container

How to make a sliding up horizontal DIV container using jquery? 如何使用jquery制作一个向上滑动的水平DIV容器? So far I have the below-provided code. 到目前为止,我有以下提供的代码。 The problem is that the content of <h1 id="filter_content">Content</h1> is initially not hidden. 问题是<h1 id="filter_content">Content</h1>内容最初未隐藏。 Also I've seen very nice looking sliding up menus, something like the first screenshot here . 我也看到了很漂亮的滑动菜单,就像这里的第一个截图。 So, when user clicks on +, the content slides up. 因此,当用户点击+时,内容会向上滑动。 Where can I actually find a sample code or some example? 我在哪里可以找到示例代码或示例?

<div id="filter">
  <h1>Filter</h1><br>
</div>
<h1 id="filter_content">Content</h1>

<script>
$('#filter').click(function() {
    if ($("#filter").is(":hidden")) {
          $("#filter_content").show("slow");
        } else {
          $("#filter_content").slideUp("slow");
        }
    });
</script>

Hiya working demo click here or Initially hidden demo here Hiya 工作演示点击这里 最初隐藏的演示在这里

using slideToggle API: good read http://api.jquery.com/slideToggle/ Will do the trick for the exact behavior you are looking for. 使用slideToggle API:好的阅读http://api.jquery.com/slideToggle/将针对您正在寻找的确切行为进行操作。

code

$('#filter').click(function() {

          $("#filter_content").slideToggle("slow");

    });
​

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM