1

jQueryScrollSpy (https://github.com/sxalexander/jquery-scrollspyhttps://github.com/sxalexander/jquery-scrollspy) を使用して設定し、div #red にスクロールすると、それぞれの子 ' .test' フェードインします。N div の一番上までスクロールすると、N の子が表示されるように設定するにはどうすればよいですか? (そして、div N を離れると消えます。)

助けてくれてありがとう、私はこの種のループを設定したことがありません。

ジョー

<script type="text/javascript">
            $(document).ready(function() {
                    $(".test").hide();

                    $('#red').each(function(i) {
                        var position = $(this).position();
                        console.log(position);
                        console.log('min: ' + position.top + ' / max: ' + parseInt(position.top + $(this).height()));
                        $(this).scrollspy({
                            min: position.top,
                            max: position.top + $(this).height(),
                            onEnter: function(element, position) {
                                if(console) console.log('entering.#red');
                                $("#red").children().fadeIn(200);},

                            onLeave: function(element, position) {
                                if(console) console.log('leaving.#red');
                                $("#red").children().fadeOut(200);}

                            /*onEnter: function(element, position) {
                                if(console) console.log('entering.#blue');
                                $(".test").show();},

                            onLeave: function(element, position) {
                                if(console) console.log('leaving.#blue');
                                $(".test").hide();}*/
                        });
                    });
                });
            </script>
4

0 に答える 0