3

私は Blogger.com にブログを持っていて、Wordpress の Dreamgrow や Qoate Scroll Triggered Box のような Scroll Triggered Box を追加したいと考えています。Scroll Triggered Box を jQuery で参照しました。HTML ファイルを作成してテストしましたが、うまくいきません。私がどこかを間違えたのかもしれません。私のコーディングは

<html>

<head>

<title>Scroll Triggered Box With jQuery</title>

<style type="text/css">
.Comments
{
font:georgia;
display:none;
}


</style>

</head>

<body>

<script type="text/javascript">
    $(document).ready(function () {
        $(window).scroll(function () {
            var y = $(window).scrollTop();
            var c = $('#comments').offset();
            if (y > (c.top - $(window).height())) {
                $('#the_box').fadeIn("slow");
            } else {
                $('#the_box').fadeOut('slow');
            }
        });
    });
</script>

<div>
<!--My long post here-->
</div>

<div class="Comments" id="the_box">
This is the DIV that triggers I scroll down to Comments</br>
This is the DIV that triggers I scroll down to Comments</br>
This is the DIV that triggers I scroll down to Comments</br>
This is the DIV that triggers I scroll down to Comments</br>
This is the DIV that triggers I scroll down to Comments</br>
This is the DIV that triggers I scroll down to Comments
</div>

</body>

</html>

私はjScriptが少し苦手です。jScript の仕組みがわかりません。

問題を解決して Blogger.com ブログで機能させるにはどうすればよいですか?

4

1 に答える 1

0

私はあなたのコードが厄介だと言うことができます。

  var a =$(window).height();
  var num = c-y;
 if (y > num){
   do your function
    }else{
  do whatever
    }
于 2012-11-08T03:39:20.810 に答える