0

なぜこれが機能しないのか、私にはよくわかりません。その右側に画像を紹介するテキストがあります。ユーザーがスクロールして画像を表示すると、テキストが徐々に消えていきます。同じコードで縦方向のテキストがフェードする例をたくさん見てきましたが、何らかの理由でこれがうまくいきません。誰かが私が間違っていることを見ていますか? 次のJavaScriptコードがあります:

<script>
    $(document).bind("projectLoadComplete", function(){
        if ($(".project_intro")[0]){
            var divs = $('.project_intro');
            $(window).bind('scroll', function () {
                var st = $(this).scrollLeft();
                divs.css({ 'opacity' : (1 - st/250) });
                if (divs.css('opacity') < 0) {
                    divs.css('opacity', 0);
                }
            });
        }
    });
</script>

そして、次の HTML コード:

<div class="project_intro">This is some intro text that I want to fade when the user scrolls left.</div>
<table height="100%" style="height: 100%; margin-left: 300px;" valign="middle">
    <tr>
        <td>{image 1}</td>
        <td>{image 2}</td>
    </tr>
</table>
4

2 に答える 2

0

http://jsfiddle.net/5xQb3/6/で jsfiddle を作成しました。

projectLoadCompleteイベントが発生bind('projectLoadComplete ')してdocument.ready()いると確信していますか?

于 2013-08-17T05:31:58.800 に答える
0
Don't go for the hardest thing dude.
Use fadeOut jquery method...
fadeOut('Ur time in milliseconds without quotes')

$(document).ready(function(){
    if ($(".project_intro")[0]){
        var divs = $('.project_intro');
        $(window).bind('scroll', function () {
            var st = $(this).scrollLeft();
           $('.project_intro').fadeOut(5000);
        });
    }
});

デモ

于 2013-10-10T10:34:19.970 に答える