0

これは、divをウィンドウに表示するのに最適ですが、アニメーションを逆にする関数を配置しようとすると(パネルが入ったのと同じように後退しますが、何も起こりません笑...私はこのjQueryが初めてです何か間違ったことをしているだけだと確信しています。

私が実現したいのは、(現在のコードのように) ウィンドウをスライドさせてから、10 秒ほど表示された後、ウィンドウを元のように後退させることです。

jQuery:

<!-- Live Support Slide-In -->
<script type="text/javascript">
$(document).ready(function() {

    // Store our panel into a variable.
    var $myPanel = $("#live-chat");

    // Get the height of the panel dynamically.
    var $myPanelHeight = parseInt($myPanel.height());

    // Immediately set the opacity to 0 - to hide it and set its bottom to minus its height.
    $myPanel.css({ "opacity" : 0, "bottom" : "-" + $myPanelHeight + "px" });

    // Set a timeout for the panel to slide and fade in.
    setTimeout(function() {

        $myPanel.animate({

            // The CSS properties we want to animate (opacity and bottom position).
            opacity: 1,
            bottom: '0'

        }, 2000, function() {

            // Animation complete. 
            // Here is where I tried putting an additional setTimeout(). Wouldn't help much, because I can't seem to reverse the animation.

                });

    }, 5000); // 30 seconds in MS

}); 
</script>
<!-- End Live Support Slide-In -->

HTML:

  <h1 class="tech" style="">Need Help?</h1>
  <p style="font-size:14px;">Don't worry! Our sales team is just one-click away. If you have questions regarding a product, your order status, etc. just click the link below and start a Live Chat session now.</p>
  <a style="display:block; text-align:right; font-weight:bold; font-size:14px;" href="#">+ Chat with a salesman</a>
  <div id="no-thanks-close"><img src="/images/components/no-thanks-close.png" alt="Close this Window..." /></div>

 </div>
</div>

どんな助けでも大歓迎です!:) よろしくお願いします!

4

1 に答える 1

0

文字通り反対のことをします。不透明度を 100% にしてから、元の「上」の位置をキャプチャし、それを関数の外の変数として保存します。あなたのトップポジションとして変数をキャッチし、理論的にはうまくいくはずです.

于 2012-07-31T01:57:26.613 に答える