通过动画缓动向上滑动和向下滑动

发布于 2024-09-09 08:19:12 字数 792 浏览 1 评论 0原文

我需要平滑的幻灯片效果,但我似乎无法理解我做错了什么。我已经尝试过以下操作,

 $(document).ready(function(){
   $('.drop2').click(function(){
       var $next = $(this).parent().next('li.drop_down2');
       if($next.is(':visible')) {
           $next.animate(     {'display':'none'}, 'slow', 'easeOutBounce');
       } else {
         $next.animate(   {'display':'block'}, 'slow', 'easeOutBounce');
       }
   });
  });

  $(document).ready(function(){
   $('.drop2').click(function(){
       var $next = $(this).parent().next('li.drop_down2');
       if($next.is(':visible')) {
           $next.slideUp({
           duration: 1000, 
           easing: easeInSine, 
           complete: callback});
       } else {
           $next.slideDown();
       }
   });
  });

为了使这种顺利的效果发生,我是否做错了什么

I need a smooth slide effect and i cant seem to understand what I am doing wrong. I have tried the following

 $(document).ready(function(){
   $('.drop2').click(function(){
       var $next = $(this).parent().next('li.drop_down2');
       if($next.is(':visible')) {
           $next.animate(     {'display':'none'}, 'slow', 'easeOutBounce');
       } else {
         $next.animate(   {'display':'block'}, 'slow', 'easeOutBounce');
       }
   });
  });

  $(document).ready(function(){
   $('.drop2').click(function(){
       var $next = $(this).parent().next('li.drop_down2');
       if($next.is(':visible')) {
           $next.slideUp({
           duration: 1000, 
           easing: easeInSine, 
           complete: callback});
       } else {
           $next.slideDown();
       }
   });
  });

Is there something I am doing wrong to make this smooth effect happen

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

阪姬 2024-09-16 08:19:12

这应该可以帮助你开始,马特:

<div class="trigger"><a href="#" onclick="return false">Expand one.</a></div>
<div class="expander">Item one is now shown.</div>

<div class="trigger"><a href="#" onclick="return false">Expand two.</a></div>
<div class="expander">Item two is now shown.</div>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js"></script>
<script>
jQuery(document).ready(function() {
    jQuery('.expander').hide();
    jQuery('.trigger').click(function() {
        jQuery(this).next('.expander').slideToggle();
    });
});
</script>

This should get you started, Matt:

<div class="trigger"><a href="#" onclick="return false">Expand one.</a></div>
<div class="expander">Item one is now shown.</div>

<div class="trigger"><a href="#" onclick="return false">Expand two.</a></div>
<div class="expander">Item two is now shown.</div>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js"></script>
<script>
jQuery(document).ready(function() {
    jQuery('.expander').hide();
    jQuery('.trigger').click(function() {
        jQuery(this).next('.expander').slideToggle();
    });
});
</script>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文