滚动位置的HTML文本更改

时间:2014-12-09 15:28:20

标签: jquery html5 css3 text scroll

我想知道如何使用jquery通过滚动位置更改段落的文本。我有滚动的图像,我希望这些图像的固定描述随着用户经过每个图像而改变。

1 个答案:

答案 0 :(得分:1)

这样的事情:

$(window).scroll(function(){
    var div = $("MyDiv").scrollTop();

    //check the scroll of the page vs the scroll of the div containing the image.
    if($(this).scrollTop() > $("MyDiv").scrollTop() + 50)
    {
         $("SomeP").text("My new text");
    }

});